Powershell 2.0 Remoting加载.Net 4.0 dll

Jar*_*314 7 powershell .net-4.0 powershell-remoting

我试图在远程Powershell 2.0会话中使用[Reflection.Assembly] :: LoadFrom加载.Net 4.0程序集.由于我对powershell.exe.config文件所做的更改,它在本地工作,但在远程会话中失败并显示"此程序集由运行时更新...构建"异常.

涉及的两台机器都有.Net 2.0和4.0,并且对x86和x64位powershell可执行文件进行了powershell.exe.config更改.我也尝试更改服务器powershell注册表项:HKLM:\ Software\Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion HKLM:\ Software\Wow6432Node\Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion

我一定错过了什么,但我不知道它是什么.

编辑: 以下是我正在执行的代码的示例.

PS C:\>Enter-PSSession -ComputerName server1
[server1]: PS C:\stuff> dir *.dll | foreach { [Reflection.Assembly]::LoadFrom( $_.FullName ) }
Run Code Online (Sandbox Code Playgroud)

Jar*_*314 7

解决的办法是创建c:\ WINDOWS\SYSTEM32\wsmprovhost.exe.config文件和交流:\ WINDOWS\Syswow64资料\ wsmprovhost.exe.config文件,在服务器上,类似于一个,我发现在:HTTP:// poshcode .COM/2045

<?xml version="1.0" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
    <supportedRuntime version="v2.0" />
  </startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我找到了以下文章,暗示需要像powershell.exe文件一样配置wsmprovhost.exe. http://tfl09.blogspot.com/2010/08/using-later-versions-of-net-framework.html