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