在 Batch 或 Powershell 上获取完整的 Windows 版本。(例如 Windows Server 2016 上的“Microsoft Windows [Version 10.0.18363.900]”

在 Batch 或 Powershell 上获取完整的 Windows 版本。(例如 Windows Server 2016 上的“Microsoft Windows [Version 10.0.18363.900]”

我有这个问题。在批处理中仅使用命令“ver”,我得到:Microsoft Windows [版本 10.0.18363.900]

我需要一个脚本的最后一个子构建版本(900)来确定 Windows 是否处于最新补丁级别(或者在检查主构建版本之后接近它)我的脚本在 Windows 10、Windows 2019 上运行良好,但在 Windows 2016 上运行不正常,因为“ver”会打印:Microsoft Windows [版本 10.0.14393]

不含子版本。选中“WinVer”时将在 GUI 上打印:版本 1607(OS 内部版本 14393.3930)

那么,在 Windows 2016 中,我可以从批处理或 powershell 中获取“3930”吗?WMI、sysinfo 等不会显示该信息。

谢谢!

答案1

它被称为更新构建修订版。使用以下命令来查询它:

Get-ItemPropertyValue 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion' 'UBR'  

相关内容