我们正在为客户端提供脚本,这些脚本只能在Powershell 2.0中运行。
通过命令,我们可以确保Powershell2.0安装如下
$version = Get-host | Select-object Version但是,如果我们提供脚本,如何确保他们从Powershell 2.0执行该脚本?
执行脚本时,Powershell 2.0特性可能会在启动脚本本身时给出脚本错误。是不是?
发布于 2012-08-02 20:23:12
我会这样做:
# get version
$ver = $PsVersionTable.psversion.major
# Check to see if it's V2
If ($ver -NE 2)
{"incorrect version - exiting; return}
# Everything that follows is V2希望这能有所帮助!
https://stackoverflow.com/questions/11771605
复制相似问题