How to find the Windows version from the PowerShell command line

前端 未结 25 1183
野的像风
野的像风 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:21

    [solved]

    #copy all the code below:
    #save file as .ps1 run and see the magic
    
     Get-WmiObject -Class Win32_OperatingSystem | ForEach-Object -MemberName Caption
     (Get-CimInstance Win32_OperatingSystem).version
    
    
    #-------------comment-------------#
    #-----finding windows version-----#
    
    $version= (Get-CimInstance Win32_OperatingSystem).version
    $length= $version.Length
    $index= $version.IndexOf(".")
    [int]$windows= $version.Remove($index,$length-2)  
    $windows
    #-----------end------------------#
    #-----------comment-----------------#
    

提交回复
热议问题