Find-PowerShellBuildStatus.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
<#
.SYNOPSIS Find latest PowerShell build status #> function Find-PowerShellBuildStatus { [CmdletBinding(DefaultParameterSetName = 'Default')] param ( [Parameter(ParameterSetName = 'Default')] [ReleaseTypes]$Release = [ReleaseTypes]::Stable, [Parameter(ParameterSetName = 'ShowAll')] [switch]$All ) switch ($PSCmdlet.ParameterSetName) { 'ShowAll' { if (-not $All.IsPresent) { return } $items = @() foreach ($r in ('Stable', 'Preview', 'LTS')) { $items += FindPowerShellBuildStatusImpl -Release $r } return $items } Default { FindPowerShellBuildStatusImpl -Release $Release } } } function FindPowerShellBuildStatusImpl ([ReleaseTypes]$Release) { $buildInfoUri = switch ($Release) { 'Preview' { 'https://aka.ms/pwsh-buildinfo-preview' } 'LTS' { 'https://aka.ms/pwsh-buildinfo-lts' } Default { # Stable is default 'https://aka.ms/pwsh-buildinfo-stable' } } $response = Invoke-RestMethod -Uri $buildInfoUri $result = [BuildStatus]::New() $result.Release = $Release $result.ReleaseDate = $response.ReleaseDate $result.BlobName = $response.BlobName $result.ReleaseTag = $response.ReleaseTag # note : https://github.com/PowerShell/PowerShell/blob/v7.0.3/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs#L376 $result.Version = [semver]($response.ReleaseTag.Substring(1)) return $result } |