PowerShell中查看目前的版本、Windows版本、.NET版本資訊的代碼_PowerShell

來源:互聯網
上載者:User

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.