How to find the Windows version from the PowerShell command line

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

    Should be easy like this :

    Get-ComputerInfo  | select windowsversion
    
    0 讨论(0)
  • 2020-12-22 16:35

    You can use python, to simplify things (works on all Windows versions and all other platforms):

    import platform
    
    print(platform.system()) # returns 'Windows', 'Linux' etc.
    print(platform.release()) # returns for Windows 10 or Server 2019 '10'
    
    if platform.system() = 'Windows':
        print(platform.win32_ver()) # returns (10, 10.0.17744, SP0, Multiprocessor Free) on windows server 2019
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-22 16:36

    To produce identical output to winver.exe in PowerShell v5 on Windows 10 1809:

    $Version = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\'
    "Version $($Version.ReleaseId) (OS Build $($Version.CurrentBuildNumber).$($Version.UBR))"
    
    0 讨论(0)
  • 2020-12-22 16:36

    Using Windows Powershell, it possible to get the data you need in the following way

    Caption:

    (Get-WmiObject -class Win32_OperatingSystem).Caption
    

    ReleaseId:

    (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId
    

    version:

    (Get-CimInstance Win32_OperatingSystem).version
    
    0 讨论(0)
  • 2020-12-22 16:37
    (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name BuildLabEx).BuildLabEx
    
    0 讨论(0)
提交回复
热议问题