There are a couple of catches to install PowerShell on macOS and have it work for remote sessions to Microsoft 365 / Azure AD / Exchange Online.
First, install the latest release version of PowerShell from GitHub:
https://github.com/PowerShell/PowerShell/releases
Then, install MacPorts
https://github.com/macports/macports-base/releases
After you have installed MacPorts, install the older version of OpenSSL that PowerShell requires. In Terminal, type:
sudo port install openssl10
After installing OpenSSL 1.0, make a symlink so that PowerShell can find it where it is looking for it
sudo mkdir -p /usr/local/opt/openssl sudo ln -s /opt/local/lib/openssl-1.0 /usr/local/opt/openssl/lib
Once this has been done, you can connect to MS365:
pwsh $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session
Still get WSMan error.
I’m not sure what’s going on – this works for me on a clean install of macOS and MacPorts…
You first need to move the /usr/local/opt/openssl symlink out of the way, before the mkdir.
Yes, good point – if this is not a clean install of macOS and Mac Ports, then there may be cruft remaining from previous installations that needs to be removed.
Removing the folder was the key! After many long attempts I removed the folder then recreated it and the link.
Awesome, it works! <3