Skip to content

Instantly share code, notes, and snippets.

@milnak
Last active November 24, 2022 02:06
Show Gist options
  • Save milnak/76635aafcc3a7cd3db1cd0ad249cdf73 to your computer and use it in GitHub Desktop.
Save milnak/76635aafcc3a7cd3db1cd0ad249cdf73 to your computer and use it in GitHub Desktop.
[Download Latest PowerShell] PowerShell script to download latest PowerShell x64 MSI from github
Function DownloadLatestPS {
Param([Parameter(Mandatory=$true)][string]$Folder)
$json = curl -s 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest' | ConvertFrom-Json
$ps = $json.assets | Where-Object name -Like 'PowerShell-*-win-x64.msi'
"Downloading: {0}" -f $ps.name
$oldpp = $progresspreference
$progresspreference = 'SilentlyContinue'
Invoke-WebRequest $ps.browser_download_url -OutFile (Join-Path $Folder $ps.name)
$progressPreference = $oldpp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment