PowerShell 的 $PSVersionTable 的内容代表什么?

Lod*_*ijk 11 powershell

如果我echo $PSVersionTable在 PowerShell 中,我得到的似乎是多位版本信息。

属性的名称是

  • CLRVersion
  • BuildVersion
  • PSVersion
  • WSManStackVersion
  • PSCompatibleVersions
  • SerializationVersion
  • PSRemotingProtocolVersion

除 1 以外的所有版本均采用普通版本符号 ( #.#.#),另外 1 个 (PSCompatibleVersions) 是一组版本号 ( {1.0, 2.0})

这些分别代表什么?


另外:创建这个问题是为了更深入地回答我在安装什么版本的 Windows 管理框架?. 那里的评论以及我链接到那里的类似问题中的其他评论表明$PSVersionTable可用于获取 WMF 的版本。如果这些属性之一确实提供了 WMF 版本,并且保证这样做,请务必在那里回答。此外,如果您可以提供任何文件或确认证据,如果可以,我会给您 +2:我的 Google 查询没有产生任何令人满意的结果。

Jos*_*non 13

PowerShell 内置帮助描述了 $PSVersionTable:

Get-Help about_Automatic_Variables
Run Code Online (Sandbox Code Playgroud)

Update-Help如果之前没有运行过,可能需要先运行。

有什么好处Get-Help是你不必确切地知道你在寻找什么。我首先输入的内容实际上只是help PSVersionTable,它列出了包含“PSVersionTable”的所有帮助主题(还有一些其他主题)。

这是 about_Automatic_Variables 的部分,描述$PSVersionTable了 PowerShell 目前为我返回的内容,但正如 OP 所指出的那样,这是最不重要的部分:

$PsVersionTable 包含一个只读哈希表,显示有关当前会话中运行的 Windows PowerShell 版本的详细信息。该表包括以下项目:

CLRVersion:                The version of the common language runtime (CLR)

BuildVersion:              The build number of the current version

PSVersion:                 The Windows PowerShell version number

WSManStackVersion:         The version number of the WS-Management stack

PSCompatibleVersions:      Versions of Windows PowerShell that are 
                           compatible with the current version

SerializationVersion:      The version of the serialization method

PSRemotingProtocolVersion: The version of the Windows PowerShell remote 
                           management protocol
Run Code Online (Sandbox Code Playgroud)