Last active
November 28, 2022 22:56
-
-
Save DanGough/5756295e4d70fcc009f63e2b5da1d2b3 to your computer and use it in GitHub Desktop.
Powershell web scraper to retrieve latest version and download URLs for Microsoft PowerBI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ProgressPreference = 'SilentlyContinue' | |
try { | |
$Version = ((Invoke-WebRequest 'https://www.microsoft.com/download/details.aspx?id=58494' -UseBasicParsing).Content | Select-String -Pattern 'Version:\s+</div><p>(.+)</p>').Matches.Groups[1].Value | |
$URL32 = ((Invoke-WebRequest 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=58494' -UseBasicParsing).Links | Where-Object href -like '*PBIDesktopSetup_x64.exe')[0].href | |
$URL64 = ((Invoke-WebRequest 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=58494' -UseBasicParsing).Links | Where-Object href -like '*PBIDesktopSetup.exe')[0].href | |
if ($Version -and $URL32) { | |
[PSCustomObject]@{ | |
Version = $Version | |
Architecture = 'x86' | |
URI = $URL32 | |
} | |
} | |
if ($Version -and $URL64) { | |
[PSCustomObject]@{ | |
Version = $Version | |
Architecture = 'x64' | |
URI = $URL64 | |
} | |
} | |
} | |
catch { | |
Write-Error 'Unable to query version and download URLs for PowerBI Desktop' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice bit