cancel
Showing results for 
Search instead for 
Did you mean: 

Download the SDK Installer

Download the SDK Installer

I got tired of checking and downloading new versions of the Orion SDK from GitHub.  OK, so I didn't exactly get tired of it, but I decided to have my computer do this for me.  So how best to do it?  PowerShell of course!

$TargetDirectory    = "C:\Place\I\Want\To\Save\The\Downloads"
$DownloadBetas      = $true
$DownloadLatestOnly = $false

$SdkPage = Invoke-WebRequest -Uri "https://github.com/solarwinds/OrionSDK/releases"
$Links = $SdkPage.Links | Where-Object { $_.innerText -like "*OrionSDK.msi*" }
$Links | Add-Member -MemberType ScriptProperty -Name IsBeta -Value { $this.href.Split("/")[-2] -like "*-beta" } -Force
$Links | Add-Member -MemberType ScriptProperty -Name Version -Value { if ( $this.IsBeta ) { [Version]( $this.href.Replace("v", "").Replace("-beta", "").Split("/")[-2] ) } else { [version]( $this.href.Replace("v", "").Split("/")[-2] ) } } -Force
$Links | Add-Member -MemberType ScriptProperty -Name Url -Value { "https://github.com$( $this.href )" } -Force
$Links | Add-Member -MemberType ScriptProperty -Name FileName -Value { "OrionSDK_$( $this.Version )$( if ( $this.IsBeta ) { "-beta" } ).msi" }
if ( $DownloadLatestOnly -and $DownloadBetas )
{
    $DownloadLinks = $Links | Sort-Object -Property Version -Descending | Select-Object -First 1
}
elseif ( $DownloadLatestOnly -and -not $DownloadBetas )
{
    $DownloadLinks = $Links | Where-Object { -not $_.IsBeta } | Sort-Object -Property Version -Descending | Select-Object -First 1
}
elseif ( -not $DownloadLatestOnly -and -not $DownloadBetas )
{
    $DownloadLinks = $Links | Where-Object { -not $_.IsBeta }
}
else # ( -not $DownloadLatestOnly -and $DownloadBetas )
{
    $DownloadLinks = $Links
}
$DownloadLinks | ForEach-Object { Invoke-WebRequest -Uri $_.Url -OutFile ( Join-Path -Path $TargetDirectory -ChildPath $_.FileName ) }

This does a few things:

1) Gets all of the MSI Downloads from the above page.

2) Adds the IsBeta and the Version members to the link objects

3) Filters (depending on the DownloadBetas and DownloadLatestOnly flags)

4) Download them.

Tags (1)
Comments

Very nice. As a reminder - I post released versions (not beta) on Chocolatey as well. https://chocolatey.org/packages/orionsdk . So "choco upgrade orionsdk" will get you current.

Great point!  Now whatever way you like to handle updates, it's there for you.

BTW - the WITH QUERYSTATS is sick!  (in the good way)

Version history
Revision #:
1 of 1
Last update:
‎07-17-2017 03:49 PM
Updated by:
 
Contributors