我正在尝试在远程 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
我一定忽略了什么,但我不知道是什么。
编辑: 以下是我正在执行的代码示例。
涉及到的两台计算机都有 .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 ) }