Finding Latest PowerShell 6 Release (and Download URLs)

by May 2, 2019

PowerShell 6 is open-source and maintained in a public repository on GitHub. There are frequent releases.

If you don’t want to dig your way through the GitHub front-end to find the download location for the latest PowerShell 6 release, here is a PowerShell way:

$AllProtocols = [Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[Net.ServicePointManager]::SecurityProtocol = $AllProtocols 

# get all releases
Invoke-RestMethod -Uri https://github.com/PowerShell/PowerShell/releases.atom -UseBasicParsing |
  # sort in descending order
  Sort-Object -Property Updated -Descending |
  # pick the first (newest) release and get a link
  Select-Object -ExpandProperty Link -First 1 |
  # pick a URL
  Select-Object -ExpandProperty HRef

(Note that explicitly enabling SSL is required only up until Windows 10 1803.)

This gets you the URL for the latest PowerShell 6 release page. On it, you find the downloads for the different supported platforms.

Then again, there is an easier way, too: navigate to https://github.com/PowerShell/PowerShell/releases/latest

However, this won’t provide you with the URL and tag information. Instead, you are simply redirected to the appropriate URL.

Here is a hybrid of both: use the shortcut to the latest release, but do not allow redirects. This way, PowerShell is reporting the complete URL back to you:

$AllProtocols = [Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[Net.ServicePointManager]::SecurityProtocol = $AllProtocols 


# add a random number to the URL to trick proxies
$url = "https://github.com/PowerShell/PowerShell/releases/latest?dummy=$(Get-Random)"

$request = [System.Net.WebRequest]::Create($url)
# do not allow to redirect. The result is a "MovedPermanently"
$request.AllowAutoRedirect=$false
# send the request
$response = $request.GetResponse()
# get back the URL of the true destination page, and split off the version
$realURL = $response.GetResponseHeader("Location")
# make sure to clean up
$response.Close()
$response.Dispose()

$realURL

psconf.eu – PowerShell Conference EU 2019 – June 4-7, Hannover Germany – visit www.psconf.eu There aren’t too many trainings around for experienced PowerShell scripters where you really still learn something new. But there’s one place you don’t want to miss: PowerShell Conference EU – with 40 renown international speakers including PowerShell team members and MVPs, plus 350 professional and creative PowerShell scripters. Registration is open at www.psconf.eu, and the full 3-track 4-days agenda becomes available soon. Once a year it’s just a smart move to come together, update know-how, learn about security and mitigations, and bring home fresh ideas and authoritative guidance. We’d sure love to see and hear from you!

Twitter This Tip! ReTweet this Tip!