Our thinking


Connect to ExchangeOnline with PowerShell from macOS – Updated for M1

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.

Leave a Reply