windowspowershellpowershell-2.0

How to find the Windows version from the PowerShell command line


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 of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify tha
t the path is correct and try again.
At line:1 char:4
+ ver <<<< 
    + CategoryInfo          : ObjectNotFound: (ver:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

How do I do this?


Solution

  • Since you have access to the .NET library, you could access the OSVersion property of the System.Environment class to get this information. For the version number, there is the Version property.

    For example,

    PS C:\> [System.Environment]::OSVersion.Version
    
    Major  Minor  Build  Revision
    -----  -----  -----  --------
    6      1      7601   65536
    

    Details of Windows versions can be found here.