PowerShell Core 中的 WS-Management (WSMan) 远程处理WS-Management (WSMan) Remoting in PowerShell Core

安装 PowerShell 可使用 和 Enter-PSSession 针对远程计算机创建 PowerShell 会话。若要使其接受传入的 PowerShell 远程连接,用户必须创建一个 WinRM 远程处理终结点。这是一个显式选择加入方案,其中用户运行 Install-PowerShellRemoting.ps1 创建 WinRM 终结点。将其他功能添加到 Enable-PSRemoting 以执行相同操作前,安装脚本是一个短期解决方案。有关详细信息,请参阅问题 。

  • 在 %windir%\System32\PowerShell 中创建插件目录
  • 将 pwrshplugin.dll 复制到该位置
  • 生成配置文件

脚本必须在管理员级别的 PowerShell 会话中执行,并且以两种模式中运行。

由其将注册的 PowerShell 实例执行Executed by the instance of PowerShell that it will register

由代表其注册实例的另一 PowerShell 实例执行Executed by another instance of PowerShell on behalf of the instance that it will register

注意: 该远程处理注册脚本将重新启动 WinRM,因此该脚本运行后所有现有 PSRP 会话会立即终止。如果在远程会话期间运行,则会终止连接。

如何连接到新的终结点How to Connect to the New Endpoint

请注意,未指定 -ConfigurationNameNew-PSSession 和 调用将以默认 PowerShell 终结点 microsoft.powershell 为目标。