了解PowerShell版本

我有一个安装了PowerShell的VPS。 我怎么知道它是RTM还是CTP?

我跑$ host.Version,我得到了:

Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1 

WTF是否定的? 我从来没有看到任何一个版本片段的负数

看起来更传统的获取版本号的方法是使用$ PSVersionTable ,它提供了一个版本版本值。 虽然$PSVersionTable.PSVersion给了我你得到什么..嗯, – build立!

如果它让你感觉更好,我在Windows 7上运行PS版本2 RTM,并且获得和你一样的结果。 我的$ PSVersionTable.BuildVersion是6.1.7600.16385这是我得到的相同的版本号,当我看着powershell.exe上的产品版本:

 (gcm "$PSHome\PowerShell.exe").FileVersionInfo.ProductVersion 

你可以得到更详细的信息,例如:

 PS > $PSVersionTable Name Value ---- ----- CLRVersion 2.0.50727.4200 BuildVersion 6.0.6002.18139 PSVersion 2.0 WSManStackVersion 2.0 PSCompatibleVersions {1.0, 2.0} SerializationVersion 1.1.0.1 PSRemotingProtocolVersion 2.1 

 PS > $Host Name : ConsoleHost Version : 2.0 InstanceId : [obscured] UI : System.Management.Automation.Internal.Host.InternalHostUserI nterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace 

我会把“-1”的值解释为“不适用”。