Libraries/Lib.Windows.WinNT.Windows.WindowsServer/Lib.Windows.WinNT.Windows.WindowsServer.psm1
<#
.SYNOPSIS Get the release ID of an OS .DESCRIPTION Windows Server (since Windows 10 / 2016) use the same ReleaseId as Windows Client. But to differentiate Servers from Clients, we will use the old "year" number like "2008", "2012r2" .PARAMETER Online True to specify to fetch information from the running OS .PARAMETER Root The path to the root of an OS. .EXAMPLE Get-OSReleaseId -Online .EXAMPLE Get-OSReleaseId -Root F:\ .NOTES General notes #> function Get-OSReleaseId { [CmdletBinding()][OutputType([String])]Param ( [Parameter(ParameterSetName = 'ONLINE')][switch]$Online, [Parameter(ParameterSetName = 'ROOT')][string]$Root ) Begin { Write-PwShFwOSEnterFunction } Process { $CurrentBuild = Get-OSKernelVersion @PSBoundParameters switch ($CurrentBuild) { # Windows Server 2000 "2195" { $releaseId = "2000" } # Windows Server 2003 "3790" { $releaseId = "2003" } "3790.1" { $releaseId = "2003sp1" } "3790.2" { $releaseId = "2003sp2" } # Windows Server 2008 "6000" { $releaseId = "2008" } "6001" { $releaseId = "2008sp1" } "6002" { $releaseId = "2008sp2" } # Windows Server 2008 R2 "7600" { $releaseId = "2008r2" } "7601" { $releaseId = "2008r2sp1" } # Windows Server 2012 "9200" { $releaseId = "2012" } # Windows Server 2012 R2 "9300" { $releaseId = "2012r2" } "9600" { $releaseId = "2012r2sp1" } # Windows Server 2016 "14393" { $releaseId = "2016" } # Windows Server 2019 "17763" { $releaseId = "2019" } # Windows Server 2022 "20348" { $releaseId = "2022" } # Windows Server 2025 "26100" { $releaseId = "2025" } Default { $releaseId = "Unknown Server Build" } } # return $Distrib + "." + $ReleaseId.replace('.','') return "$ReleaseId" } End { Write-PwShFwOSLeaveFunction } } |