且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

哪个.NET版本是我PowerShell脚本使用?

更新时间:2023-12-04 22:15:46

在PowerShell 2.0中,只需要一偷看 $ PSVersionTable 变量:

On PowerShell 2.0, just take a peek at the $PSVersionTable variable:

PS> $psversiontable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.4927
BuildVersion                   6.1.7600.16385
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

在PowerShell 1.0中,使用 [统环境] ::版

On PowerShell 1.0, use [System.Environment]::Version:

PS> [Environment]::Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      50727  4927