Skip to content

Instantly share code, notes, and snippets.

@tomtorggler
Created April 16, 2017 16:24
Show Gist options
  • Save tomtorggler/88d9441a38c83667eaddb410c1408966 to your computer and use it in GitHub Desktop.
Save tomtorggler/88d9441a38c83667eaddb410c1408966 to your computer and use it in GitHub Desktop.
# check if a new release of PowerShell Core is available on GitHub
function Test-PSVersionGitHub {
try {
# get latest release from github atom feed
$Release = Invoke-RestMethod https://github.com/PowerShell/PowerShell/releases.atom -ErrorAction Stop | Select-Object -First 1
} catch {
Write-Warning "Could not check for new version. $_ `n"
break
}
# extract information from atom response
$GitId = $Release.id -split "/" | Select-Object -Last 1
$Download = -join("https://github.com",$Release.link.href)
# Add information to dictionary for output
$output = [ordered]@{
"PSVersion" = $PSVersionTable.PSVersion;
"GitCommitId" = $PSVersionTable.GitCommitId;
"GitHubReleaseVersion" = $GitId;
"GitHubReleaseLink" = $Download;
}
Write-Output (New-Object -TypeName psobject -Property $output)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment