哪个.NET版本是我PowerShell脚本使用? [英] Which .NET version is my PowerShell script using?

查看:289
本文介绍了哪个.NET版本是我PowerShell脚本使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用.NET在一些PowerShell脚本我要写? - 我怎么知道/声明哪些.NET版本我处理时,这些脚本运行

I'd like to use .NET in some PowerShell scripts I'm about to write -- how do I know/declare which version of .NET I'm dealing with when these scripts run?

和有可能要选择针对其.NET版本我的脚本运行?

And is it possible to choose against which version of .NET my script will run?

推荐答案

在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

这篇关于哪个.NET版本是我PowerShell脚本使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆