macOS pwsh 错误 "no supported WSMan client library was found."

Error "no supported WSMan client library was found." with macOS pwsh

从 macOS 终端,当我执行时:

pwsh -command "Enter-PSSession myhost"

我从 PowerShell 收到错误:

Enter-PSSession: This parameter set requires WSMan, and no supported WSMan client
library was found. WSMan is either not installed or unavailable for this system.

我花了 2 个小时才找到解决方案。我要回答我自己的问题。

问题的根本原因是 Powershell 依赖于以前的 openssl 版本。根据 GitHub issue PowerShell/#5561.

显然不容易修复

这是我找到的解决方法:

curl -L https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb \
  -o openssl.rb
brew install ./openssl.rb

这是我所做的:

pwsh -Command 'Install-Module -Name PSWSMan'
sudo pwsh -Command 'Install-WSMan'

见马特·桑顿:Exchange Online Powershell on macOS

下面在 MacOS 11.6 上测试

  1. brew install powershell
  2. brew install openssl
  3. pwsh
  4. Install-Module -Name PowerShellGet
  5. Install-Module -Name PSWSMan
  6. sudo pwsh -Command 'Install-WSMan'

以下内容适用于 Mac,没有问题。

pwsh -Command 'Install-Module -Name PSWSMan'

sudo pwsh -Command 'Install-WSMan'