To Get Windows Version as String:
(Get-WmiObject -class
Win32_OperatingSystem).Caption
[deesee1]: PS C:\Users\kimconnect> (Get-WmiObject -class Win32_OperatingSystem).Caption
Microsoft Windows Server 2012 R2 Standard
To Get Windows Version as Release Number:
[System.Environment]::OSVersion
[deesee1]: PS C:\Users\kimconnect> [System.Environment]::OSVersion
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 6.3.9600.0 Microsoft Windows NT 6.3.9600.0