Skip to content

Instantly share code, notes, and snippets.

@DanGough
Last active November 28, 2022 22:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanGough/5756295e4d70fcc009f63e2b5da1d2b3 to your computer and use it in GitHub Desktop.
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
$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'
}
@JARich2006
Copy link

nice bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment