如何创建 32 位远程 powershell 会话(在 64 位机器上)?

Jay*_*uzi 10 powershell 64-bit 32-bit

在本地 64 位机器上,我可以打开“PowerShell (x86)”。但是,如果我对另一台运行 64 位操作系统的机器执行“Enter-PSSession”,它会创建一个 64 位 PowerShell。

在我的场景中,我需要一个 32 位的 PowerShell 会话。我怎样才能得到一个?

Jay*_*uzi 15

我找到了答案。您必须使用该-ConfigurationName参数,如下所示:

Enter-PSSession -ComputerName COMPUTERNAME -ConfigurationName Microsoft.PowerShell32
Run Code Online (Sandbox Code Playgroud)

您可以通过以下方式获取可用配置列表:

Get-PSSessionConfiguration
Run Code Online (Sandbox Code Playgroud)

请注意,这些配置特定于远程机器。在我的快速测试中,32 位操作系统只有Microsoft.PowerShell32 位,而 64 位操作系统有Microsoft-PowerShell64 位和Microsoft-PowerShell3232 位。

  • 此外,如果 Microsoft.PowerShell32 在您的 64 位计算机上不可用,您可以使用以下方法注册它:Register-PSSessionConfiguration Microsoft.PowerShell32 -processorarchitecture x86 -force (4认同)