Recipes by topic

Windows version and build

Win32_OperatingSystem gives the edition name, the version number and the build.

Get-CimInstance -ClassName Win32_OperatingSystem |
    Select-Object -Property @(
        'CSName'
        'Caption'
        'Version'
        'BuildNumber'
        'OSArchitecture'
        'InstallDate'
    )

Version looks like 10.0.26100: the first two numbers are shared by Windows 10 and 11, the third is the build number. The release name (for example 24H2) and the revision number (UBR) are not in this class: they are read from the registry. InstallDate is the date Windows was installed, not the date of the last update.

Variant: remote

Sorting by build brings out the machines that are behind.

$cimSession = New-CimSession -ComputerName 'SERVER01', 'SERVER02'
try {
    $cimParameters = @{
        CimSession = $cimSession
        ClassName  = 'Win32_OperatingSystem'
    }
    Get-CimInstance @cimParameters |
        Select-Object -Property PSComputerName, Caption, Version, BuildNumber |
        Sort-Object -Property BuildNumber
} finally {
    Remove-CimSession -CimSession $cimSession
}

Classes used

← All recipes