小编典典

如何从 PowerShell 命令行查找 Windows 版本

all

如何找到我正在使用的 Windows 版本?

我正在使用 PowerShell 2.0 并尝试过:

PS C:\> ver
The term 'ver' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify tha
t the path is correct and try again.
At line:1 char:4
+ ver <<<< 
    + CategoryInfo          : ObjectNotFound: (ver:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我该怎么做呢?


阅读 87

收藏
2022-09-02

共1个答案

小编典典

由于您可以访问 .NET 库,因此您可以访问该类的OSVersion属性System.Environment来获取此信息。对于版本号,有Version属性。

例如,

PS C:\> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
6      1      7601   65536

可以在此处找到 Windows 版本的详细信息。

2022-09-02