How do I find which Windows version I\'m using?
I\'m using PowerShell 2.0 and tried:
PS C:\\> ver
The term \'ver\' is not recognized as the name o
This is really a long thread, and probably because the answers albeit correct are not resolving the fundamental question. I came across this site: Version & Build Numbers that provided a clear overview of what is what in the Microsoft Windows world.
Since my interest is to know which exact windows OS I am dealing with, I left aside the entire version rainbow and instead focused on the BuildNumber. The build number may be attained either by:
([Environment]::OSVersion.Version).Build
or by:
(Get-CimInstance Win32_OperatingSystem).buildNumber
the choice is yours which ever way you prefer it. So from there I could do something along the lines of:
switch ((Get-CimInstance Win32_OperatingSystem).BuildNumber)
{
6001 {$OS = "W2K8"}
7600 {$OS = "W2K8R2"}
7601 {$OS = "W2K8R2SP1"}
9200 {$OS = "W2K12"}
9600 {$OS = "W2K12R2"}
14393 {$OS = "W2K16v1607"}
16229 {$OS = "W2K16v1709"}
default { $OS = "Not Listed"}
}
Write-Host "Server system: $OS" -foregroundcolor Green
Note: As you can see I used the above just for server systems, however it could easily be applied to workstations or even cleverly extended to support both... but I'll leave that to you.
Enjoy, & have fun!