zondag 5 maart 2017

Display new and old style Windows OS versioning in PowerShell

The program winver.exe (About Windows) displays Windows OS version information by combining registry data values. I wrote a small PowerShell script to show the differences between the new (=> v10.0) and the old (<= v6.3) OS versioning format. Tested on Windows 8.1, Windows 10 and Windows Server 2012 R2.

W10 winver.ps1
W10 winver.ps1
The variable MMBR strings the major, minor, build and revision number together. If the registry has no entry for the major or minor number, the missing value in MMBR is shown as EMPTY. If the major and the minor value are both missing, they get replaced by the old version number.

W12R2 winver.ps1
W12R2 winver.ps1

winver.exe
winver.exe old and new versioning

winver_0.2.ps1:

# Ron Bos, rethinkit.nl, 2017, v0.2
write-host `
`n"Edition:"(gp 'HKLM:Software\Microsoft\Windows NT\CurrentVersion').ProductName `
`n"Version:"([String]$Version=(gp 'HKLM:Software\Microsoft\Windows NT\CurrentVersion').CurrentVersion)`
`n"Release:"(gp 'HKLM:Software\Microsoft\Windows NT\CurrentVersion').ReleaseID `
`n `
`n"Major:"([String]$Major=(gp 'HKLM:Software\Microsoft\Windows NT\CurrentVersion').CurrentMajorVersionNumber) `
`n"Minor:"([String]$Minor=(gp 'HKLM:Software\Microsoft\Windows NT\CurrentVersion').CurrentMinorVersionNumber) `
`n"Build:"([String]$Build=(gp 'HKLM:Software\Microsoft\Windows NT\CurrentVersion').CurrentBuild) `
`n"Revis:"([String]$Revision=(gp 'HKLM:Software\Microsoft\Windows NT\CurrentVersion').UBR)

if (($Major) -and ($Minor)) {
$MMBR=(echo MMBR : $Major"."$Minor"."$Build"."$Revision)
write-host $MMBR -foregroundcolor green
}
if (($Major) -and !($Minor)) {
$MMBR=(echo MMBR : $Major"."EMPTY"."$Build"."$Revision)
write-host $MMBR -foregroundcolor green
}
if (!($Major) -and ($Minor)) {
$MMBR=(echo MMBR : EMPTY"."$Minor"."$Build"."$Revision)
write-host $MMBR -foregroundcolor green
}
if (!($Major) -and !($Minor)) {
$MMBR=(echo MMBR : $Version"."$Build"."$Revision)
write-host $MMBR -ForeGroundColor green
}
pause

Geen opmerkingen:

Een reactie plaatsen