如果我在PowerShell中echo $PSVersionTable
,我会得到似乎是多个版本信息的位。
名称的属性是
CLRVersion
BuildVersion
PSVersion
WSManStackVersion
PSCompatibleVersions
SerializationVersion
PSRemotingProtocolVersion
除1之外的所有版本均为正常版本的符号( #.#.#
),另外1个(PSCompatibleVersions)是一组版本号( {1.0, 2.0}
1.0,2.0 {1.0, 2.0}
)
这些代表什么?
另外:这个问题是为了回应我在安装Windows Management Framework的哪个版本时提出的另一个问题而深入研究的。 。 那里的评论,以及我在那里提到的类似问题中的其他评论,都表明$PSVersionTable
可以用来获得WMF的版本。 如果其中一个属性确实给出了WMF版本,并且保证这样做,那么请务必在那里回答。 另外,如果你能提供任何文件或确认的证据,我会给你+2,如果我可以的话:我的谷歌查询并没有产生任何令人满意的结果。
PowerShell内置的帮助描述$ PSVersionTable:
Get-Help about_Automatic_Variables
如果您以前没有运行过,则可能需要先运行Update-Help
。
Get-Help
有什么好处,你不必确切地知道你在找什么。 我所input的首先find这个主题实际上只是help PSVersionTable
,它列出了包含“PSVersionTable”(还有其他一些)的所有帮助主题。
这是描述$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
根据我的经验,PSVersion(PowerShell版本)与WMF版本相匹配,至less就主版本号而言。 我没有跟踪所有的预览版本,看看如何匹配,但。