【发布时间】:2015-07-24 13:39:34
【问题描述】:
是否可以通过我们需要的 .NET CLR 版本来运行 powershell?
使用 Powershell V2 的系统默认使用 CLR 版本 2,我们需要版本 4。
我们可以实现一个配置文件来:
- C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe.config
- C:\Windows\System32\WindowsPowerShell\v1.0\PowerShellISE.Exe.config
- C:\Windows\SysWOW64\WindowsPowerShell\v1.0\PowerShell.exe.config
- C:\Windows\SysWOW64\WindowsPowerShell\v1.0\PowerShellISE.exe.config
点赞this:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
但我们不希望对客户服务器进行更改,这可能会破坏其他依赖 PowerShell 的程序。
【问题讨论】:
-
This question 有一些有趣的答案,特别是 this one 关于使用 .NET 4 一次性调用的激活配置文件。
标签: c# windows powershell