Created
April 16, 2017 16:24
-
-
Save tomtorggler/88d9441a38c83667eaddb410c1408966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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