远程运行命令时如何更改Powershell CLR版本? [英] How to change Powershell CLR version when running commands remotely?

查看:93
本文介绍了远程运行命令时如何更改Powershell CLR版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在远程服务器上运行某些脚本时遇到问题。

I've got a problem trying to run some of our scripts on a remote server.

我们需要所有Powershell会话来加载CLR的v4,

We need all Powershell sessions to load v4 of the CLR, as we're loading in our own custom binaries with our scripts.

我们已经做了一段时间了(我们使用类似于以下内容的修改后的powershell.exe.config来执行此操作:此处:如何使用.NET 4运行PowerShell运行时?),当您将RDP导入 Server1并打开Powershell会话时,一切都很好。变量$ PSVersionTable告诉我们CLR v4已加载。

We've been doing this for some time (we do so using a modified powershell.exe.config similar to here: How can I run PowerShell with the .NET 4 runtime?), and all is well when you RDP into 'Server1' and open a Powershell session. The variable $PSVersionTable tells us that the CLR v4 is loaded.

现在,我们试图通过远程运行这些命令来简化事情,我们遇到了问题:当您在同一台服务器上输入一个远程Powershell会话,$ PSVersionTable仅显示v2 ...

Now that we're trying to streamline things by running these commands remotely we run into our problem: when you enter a remote Powershell session into the same server, $PSVersionTable shows only v2...

因此,问题在于,如果在Server1上打开本地Powershell会话,则会加载v4 ,但是如果您从Server2远程到Server1,它将仅加载v2。

So the problem is that if you open a local Powershell session on Server1 it loads v4, but if you remote from Server2 to Server1 it only loads v2.

有人知道如何告诉Powershell将CLR v4用于远程会话吗?

Anybody know how to tell Powershell to use CLR v4 for remote sessions? Any help would be much appreciated!

推荐答案

尝试创建 c:\windows\System32\像这样的64位操作系统中的\wsmprovhost.exe.config 文件和 c:\windows\SysWOW64\wsmprovhost.exe.config 文件:

<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
         <supportedRuntime version="v4.0.30319"/>        
         <supportedRuntime version="v2.0.50727"/>        
    </startup>
</configuration>

这篇关于远程运行命令时如何更改Powershell CLR版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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