PowerShell查看目前的版本、Windows版本、.NET版本資訊
有很多cmdlet或者cmdlet的參數,在PowerShell不同的版本中,支援得不一樣。所以,弄清楚當前PowerShell的版本資訊是非常重要的一件事情。那麼怎麼查看當前PowerShell的版本資訊呢?洪哥向大家介紹兩個方法:
其實就是兩個PowerShell的環境變數,一個是$psversiontable,另一個是$host。
有很多cmdlet或者cmdlet的參數,在PowerShell不同的版本中,支援得不一樣。所以,弄清楚當前PowerShell的版本資訊是非常重要的一件事情。那麼怎麼查看當前PowerShell的版本資訊呢?洪哥向大家介紹兩個方法:
其實就是兩個PowerShell的環境變數,一個是$psversiontable,另一個是$host。
先看看$psversiontable,這個變數拆開來看就是ps-version-table,表示PowerShell中各組件的版本號碼列表。其中表示PowerShell自己的版本號碼(PSVersion),也包括.NET的版本號碼(CLRVersion),還有Windows版本號碼(BuildVersion),其它的就不一一數了,其實也沒有完全搞明白,呵呵。
PS C:\Users\zhanghong> $psversiontable
Name Value
---- -----
CLRVersion 2.0.50727.4984
BuildVersion 6.1.7600.16385
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
接下來看看$host變數,裡面一個Version,表示PowerShell的版本號碼。
PS C:\Users\zhanghong> $host
Name : ConsoleHost
Version : 2.0
InstanceId : 38d7558e-1810-446d-a81c-41fb6d40ac13
UI : System.Management.Automation.Internal.Host.InternalHostUserI
nterface
CurrentCulture : zh-CN
CurrentUICulture : zh-CN
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace