How to find the Windows version from the PowerShell command line

前端 未结 25 1086
野的像风
野的像风 2020-12-22 15:51

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         


        
25条回答
  •  执念已碎
    2020-12-22 16:31

    You could also use something like this, by checking the OSVersion.Version.Major:

    IF ([System.Environment]::OSVersion.Version.Major -ge 10) {Write-Host "Windows 10 or above"}
    IF ([System.Environment]::OSVersion.Version.Major -lt 10) {Write-Host "Windows 8.1 or below"}
    

提交回复
热议问题