Answers:
GUI:设置,系统,关于
不知道这是否是“正确”的方法,但是您可以通过以下cmd 获得Win10语音/有争议的“版本”(1511、1607等):
Reg Query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ReleaseId
这是Microsoft的页面,用于将内部版本号与Win10“版本”相关联(以防万一,请使用备用链接[wiki])。当我从远程PC获得构建版本时对我有帮助:wmic /node:HOSTNAME os get BuildNumber
(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId
(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name CurrentBuildNumber).CurrentBuildNumber
或(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name CurrentBuild).CurrentBuild
作为内部版本号
检查Windows 10的版本或内部版本号不是很有帮助,因为它不会随时间变化。
事实证明,第一句话是错误的。在所有以前的Windows版本中都是如此,但是我们现在处在一个新的Windows 10世界中。最新的内部人员内部版本的内部版本号10525
与“ RTM”相比:10240
。
有几种方法可以在命令行上获取内部版本号:
systeminfo.exe
(Get-CimInstance -ClassName Win32_OperatingSystem -Namespace root/cimv2).BuildNumber
(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name CurrentBuild).CurrentBuild
这三个中的最后一个是最快的。
如果您更喜欢GUI,则可以使用winver.exe或大多数Windows桌面应用程序菜单中的About
条目Help
。
由于没有任何Service Pack,操作系统上的补丁程序级别取决于安装的更新。有几种找到它们的方法,GUI,systeminfo.exe,wmi等。
推荐的最有效的方法是使用PowerShell:
Get-HotFix
显示如下:
Source Description HotFixID InstalledBy InstalledOn
------ ----------- -------- ----------- -----------
WIN10 Security Update KB3074663 NT AUTHORITY\SYSTEM 7/17/2015 12:00:00 AM
WIN10 Security Update KB3074667 NT AUTHORITY\SYSTEM 7/21/2015 12:00:00 AM
WIN10 Security Update KB3074674 NT AUTHORITY\SYSTEM 7/24/2015 12:00:00 AM
WIN10 Update KB3074678 NT AUTHORITY\SYSTEM 7/31/2015 12:00:00 AM
您可以过滤最近10天内的更新:
Get-Hotfix | Where {$_.InstalledOn -gt $(Get-Date).AddDays(-10) -and $_.Description -eq "Update"}
或显示最近安装的三个更新:
Get-Hotfix | Sort-object InstalledOn -Descending | Select -First 3
您可以检查是否安装了特定的更新:
if ((get-hotfix -id kb3087916) -ne $null) {"patched..."}
您可以先在网上找到最新的补丁kb编号,例如:
(New-Object Net.WebClient).DownloadString('https://microsoft.com/...')
然后检查它是否存在于机器上。
注意:这仅是示例。我不知道当前列出这些内容的页面,您仍然必须对其进行解析。
问题是:随着时间的流逝,Microsoft会否对Windows 10的功能进行如此大的更改,以至于您必须对其进行检查才能使您的应用程序或脚本正常工作。
最好检查系统上是否存在所需的特定功能,而不要查找版本号。
WMI当前不具有可用于完全识别Windows 10版本(例如1607)或完整内部版本号(例如10.0.14393.577)的属性。正如在其他评论说,这个信息就是在这个项下的注册表可见:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
该键中的以下值对应于winver.exe程序显示的信息:
ReleaseID = Version (name based on year/month of release: 1507, 1511, 1607, 1703, etc.)
CurrentBuild or CurrentBuildNumber = OS Build (part before period)
UBR = OS Build (part after period)
此外,版本号在该注册表项的以下两个值中:
CurrentMajorVersionNumber = 10
CurrentMinorVersionNumber = 0
当版本(如1607)更改或安装Insider构建时,构建也会更改。但是,UBR(更新版本修订)确实会随着Microsoft版本列表中指示的某些更新而更改。
在PowerShell中,
[System.Environment]::OSVersion.Version
返回与注册表项相同的Major,Minor和Build,但它似乎始终将Revision报告为0。Reddit用户的一点代码提供了足够的替换,包括注册表中的UBR作为Revision号:
$WinVer = New-Object -TypeName PSObject
$WinVer | Add-Member -MemberType NoteProperty -Name Major -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentMajorVersionNumber).CurrentMajorVersionNumber
$WinVer | Add-Member -MemberType NoteProperty -Name Minor -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentMinorVersionNumber).CurrentMinorVersionNumber
$WinVer | Add-Member -MemberType NoteProperty -Name Build -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentBuild).CurrentBuild
$WinVer | Add-Member -MemberType NoteProperty -Name Revision -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' UBR).UBR
$WinVer
我已经被问过几次了,所以我认为我会发布它。有三种方法。
有关更多详细信息,请参见此处:http : //mythoughtsonit.com/2015/07/what-build-version-of-windows-10-am-i-running/
WMIC QFE GET HotfixID, InstalledOn, Description | FINDSTR /I "KB3081438"
,确定是否已安装2015年8月15日的CU。空白的InstalledOn日期表示它们尚未重新启动系统以完成安装。
以前发布的方法均无法正常工作,并且都无法按照“设置” →“ 关于”部分中显示的方式进行操作系统构建。它缺少累积更新信息。
你可以做这样的事情
$OSmBuild = (Get-WmiObject Win32_OperatingSystem).Version
if($OSmBuild -eq '10.0.10586')
{
# Windows 10.0.10586.0
$164 = Get-HotFix | where { $_.HotFixID -eq 'KB3140768' }
$122 = Get-HotFix | where { $_.HotFixID -eq 'KB3140743' }
$104 = Get-Hotfix | where { $_.HotfixID -eq 'KB3135173' }
if($104 -and (!($122)) -and (!($164)))
{
Write-Host '104 installed'
}
elseif($104 -and $122 -and (!($164)))
{
Write-Host '122 installed'
}
elseif($104 -and $122 -and $164)
{
Write-Host '164 installed'
}
}
在PowerShell脚本中,但它始终是一成不变的,并且使其监视起来更加困难。您可以在此处查看更新:
希望Microsoft将更新其补丁程序,以便他们开始修改BuildNumber。
Win32_OperatingSystem.Version
应该按照您描述的方式工作,但是构建会根据每个版本进行更改winver
(换句话说,我是说您的脚本有问题)。
您可以从注册表中提取版本。这是执行此操作的PowerShell snipit:
function Get-RegistryValue($key, $value) {
(Get-ItemProperty $key $value).$value
}
$a1 = Get-RegistryValue "HKLM:\software\microsoft\windows nt\currentversion" CurrentBuild
$a2 = Get-RegistryValue "HKLM:\software\microsoft\windows nt\currentversion" UBR
Write-Host Version $a1'.'$a2
PowerShell始终是答案:
Get-CimInstance win32_operatingsystem
更多信息:
Get-CimInstance Win32_OperatingSystem | Select-Object buildnumber,version
返回值:
内部版本号
----------- -------
10240 10.0.10240
您可以使用它来真正快速地获取该信息,此外,您可以将其构建为一个功能,并在需要时用于从整个车队中获取该信息。
在AD域中,可以使用PowerShell的Get-ADComputer cmdlet
Get-ADComputer -Filter {OperatingSystem -eq "Windows 10 Pro"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemVersion -Wrap -Auto
您可以在FOR命令中使用Reg Query来获取Buildversion,例如1607:
for /f "usebackq skip=2 tokens=3" %f in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ReleaseID`) do (set buildver=%f)
在尝试找到一种显示单个远程计算机的Windows 10版本及其修订版的方法时,我注意到PowerShell的版本修订版紧随Windows版本。
它导致我构建以下脚本。我添加了一个测试,以了解远程计算机是否需要重新启动才能完成更新。
$OSChecked = (Read-Host "Computer Name?")
if (Test-Connection -ComputerName $OSChecked -Count 1 -ErrorAction SilentlyContinue)
{
if ($((Get-Service WinRM -ComputerName $OSChecked).Status) -eq "stopped")
{
(Get-Service WinRM -ComputerName $OSChecked).Start()
}
Write-Host "`n$((Get-WmiObject win32_computersystem -ComputerName $OSChecked).Name) " -NoNewline ; Invoke-Command -ComputerName $OSChecked -ScriptBlock{if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction SilentlyContinue) {Write-Host "Restart Required!" -BackgroundColor DarkYellow -ForegroundColor White}}
Invoke-Command -ComputerName $OSChecked -ScriptBlock{Write-Host "Version $((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ProductName) $((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId), revision $(($PSVersionTable).PSVersion.Revision)"}
}
这给出了这种类型的结果:
Computer_Name Version Windows 10 Enterprise 1703, revision 296
在AD域中,可以用包含OU的整个计算机的变量替换单个<Computer_Name>。
Write-Host "Version $((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ProductName) $((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId), revision $(($PSVersionTable).PSVersion.Revision)"
,但是它给了我Windows 10 Pro 1803, revision 1000
10.0.17730.1000的信息,这是不正确的。构建版本为17730
我们需要验证安装了哪个累积补丁才能合规。使用get-hotfix可以工作,但是如果安装了更高版本的累积修补程序,则会导致问题。最好的解决方案是比较内部版本号,包括修补程序部分。通过命令行获得此命令的唯一方法是使用命令提示符ver命令,该命令在PowerShell中无法直接运行。
$verstring = cmd.exe /c ver
[version]$Winbuild = [regex]::Match($verstring,"(\d+\.\d+\.\d+\.\d+)").value
if ($verstring -ge [version]"10.0.16299.755") {write-host "Compliant"}