** Edit. There is a new version of this post that works for me on both of my Apple Silicon Macs. Disregard the instructions below, unless you’re on Intel, and head over to the newer post instead:
I have written a post previously on how to set up PowerShell on a Mac to connect to Exchange Online. There have been some slight changes, so I thought I’d just make a new article here, including how to get it working on Apple Silicon Macs.
This method works, and has been tested on Intel and Apple Silicon Macs.
I have only tested this with PowerShell 7.1.x, on arm64 (using Rosetta 2) and x86_64. I have not yet tested it with PowerShell 7.2.x or higher, which comes in a native arm64 build.
First of all, grab the x86_64 version of PowerShell from the Releases page.
https://github.com/PowerShell/PowerShell/releases
Install this as normal.
Next up, install the relevant version of MacPorts for your OS
https://github.com/macports/macports-base/releases
Once they are both installed, install OpenSSL from MacPorts. If you’re on an Intel based Mac, simply type sudo port install openssl
however if you are on an Apple Silicon Mac, type sudo port install openssl +universal
This step of installing the Universal build of OpenSSL is critical to getting everything working together on Apple Silicon.
Next, you need to install PSWSman and the Exchange Online Management modules.
Launch PowerShell as root via sudo pwsh
Once you’re in PowerShell, run the following commands:
Install-Module -Name PSWSMan Install-WSMan Install-Module -Name ExchangeOnlineManagement exit
Technically, only the Install-WSMan command needs to be run as root, so if you’re feeling paranoid you can adjust these instructions to suit.
Once this has completed, you can launch PowerShell once more and connect to Exchange Online via Connect-ExchangeOnline
This connection method will then launch your preferred browser to authenticate, including handling any MFA prompts, and then pass an authentication token back to the PowerShell session.
Note that on an Apple Silicon machine, the entirety of this toolchain (PowerShell, WSMan and OpenSSL) will be running as x86_64 binaries under Rosetta. As we have installed a Universal version of OpenSSL, Rosetta will be able to use the x86_64 version, whereas any arm64 binaries that need to use the OpenSSL libraries will be able to use the native version.
Jordan Borean is working on an arm64 version of omi (PSWSman) however it will likely be some time before the ExchangeOnlineManagement modules are also ported to arm64, so at this stage running everything under Rosetta is the best solution on Apple Silicon.
Many thanks for this – a great help.
I used to be able to connect to Exchange Online, but since I upgraded to Big Sur and now Monterey that hadn’t been possible. A couple of things of note, I had to run these commands instead of what you suggested:
pwsh -Command ‘Install-Module -Name PSWSMan’
sudo pwsh -Command ‘Install-WSMan’
Installing OpenSSL and upgrading PowerShell can be done with brew if you not using MacPorts
Dumb question, why can’t the module use the openssl that is included in macOS?
When this whole saga started, Apple were shipping a very old version of OpenSSL with macOS, and it was not compatible with PowerShell and WSMan. I believe in later versions of macOS, Apple are now shipping LibreSSL as a drop-in replacement for OpenSSL (due to GPL licensing requirements being incompatible with closed-source software) and now it’s entirely possible that LibreSSL might work for WSMan, but I haven’t tested it.
In the Microsoft version of WSMan (which is used for remote PowerShell connections) it had hard-coded paths for dynamic libraries that assumed the end user would be using Homebrew, so it didn’t work with OpenSSL from MacPorts, nor did it work with the old and broken version of OpenSSL that Apple had pre-installed.
With Jborean’s WSMan libraries, they are more flexible in which version of OpenSSL they use. I got it working with OpenSSL from MacPorts, but haven’t tried it with the built-in OpenSSL that comes from LibreSSL that current versions of macOS install.
On my macOS Monterey system, I have /opt/local/bin/openssl which is IpenSSL 3.0.1 and then the Apple version of OpenSSL in /usr/bin/openssl is LibreSSL 2.8.3.
The following error occurs during the connection:
Exception: Connecting to remote server outlook.office365.com failed with the following error message : error:16000069:STORE routines::unregistered scheme For more information, see the about_Remote_Troubleshooting Help topic.
I dunno, I have not seen that error before.
I have an updated post with step-by-step instructions that worked for me on both of my Apple Silicon machines. Check it out here:
https://automatica.com.au/2021/12/connect-to-exchange-online-using-powershell-on-macos-now-100-native-arm64-apple-silicon/
I’m not sure whether you ever solved this error, but the fix is to su to an admin account first, then you’ll be able to connect.
Yes, I did find a solution and put it up in a new post instead of making more edits to this older one.
https://automatica.com.au/2021/12/connect-to-exchange-online-using-powershell-on-macos-now-100-native-arm64-apple-silicon/