How to find the Windows version from the PowerShell command line

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

    I took the scripts above and tweaked them a little to come up with this:

    $name=(Get-WmiObject Win32_OperatingSystem).caption
    $bit=(Get-WmiObject Win32_OperatingSystem).OSArchitecture
    
    $vert = " Version:"
    $ver=(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId
    
    $buildt = " Build:"
    $build= (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").BuildLabEx -match '^[0-9]+\.[0-9]+' |  % { $matches.Values }
    
    $installd = Get-ComputerInfo -Property WindowsInstallDateFromRegistry
    
    Write-host $installd
    Write-Host $name, $bit, $vert, $ver, `enter code here`$buildt, $build, $installd
    

    To get a result like this:

    Microsoft Windows 10 Home 64-bit Version: 1709 Build: 16299.431 @{WindowsInstallDateFromRegistry=18-01-01 2:29:11 AM}

    Hint: I'd appreciate a hand stripping the prefix text from the install date so I can replace it with a more readable header.

提交回复
热议问题