Exchange Online Powershell on macOS

Tue, Mar 2, 2021 2-minute read

Update: 06/01/2022

Just tried this all on macOS 12.0.1 (Monterey) and it was all fine. The only difference was that (a) Homebrew moaned that Xcode was out of date, so that needed a 12gb update, and (b) Powershell moaned about using stuff from an untrusted repository. In the end I trusted PSGallery by using:

Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted

In fact the only real issue was the horrific shade of yellow that the highlighting decided to use for cmdlet names!

Original

A while ago, I ‘eugh-ed’ over the steps required to get remote powershell working even in Windows. I think back then this would never have worked on macOS, but here we are, a little less than a year later, and I’ve for some reason got it working on macOS Big Sur.

The scenario was - as you would expect little less - somewhat convoluted. I was trying to configure Room Lists in Exchange Online which - is easy to create a Room Mailbox in Exchange Admin, but they are not usable unless you can then connect via remote powershell and enable room lists. Bit of a facepalm, obvs.

So when faced with this, I was reminded that some time ago I cleaned up my mac, which meant squirreling away my now mostly unused Windows VMs. I couldn’t bring myself to move 3ft to my right to get my storage disk, so instead set about trying to get Powershell on macOS working. It wasn’t too bad, but I did disappear down a bit of a rabbit hole when I hit an issue with OMI. I’ll spare you the drama.

So here’s what you do. This is on macOS Big Sur latest (11.2.1 at time of writing.) It does assume you have homebrew installed. It’s mostly join the dots, so if you get issues along the way, just do what you’re told. You will get warnings about untrusted galleries - you make a call on whether this is OK to you.

  1. brew install powershell
  2. brew install openssl

You may get

Warning: openssl@1.1 1.1.1g is already installed and up-to-date
To reinstall 1.1.1g, run `brew reinstall openssl@1.1`

which is OK.

Also, consider running:

export PATH=”/usr/local/opt/openssl@3/bin:$PATH”

to add OpenSSL to your environment vars.

  1. pwsh

  2. Install-Module -Name PowerShellGet (source)

  3. Install-Module -Name ExchangeOnlineManagement

  4. Install-Module -Name PSWSMan

  5. sudo pwsh -Command ‘Install-WSMan'

  6. Restart powershell

  7. Import-Module ExchangeOnlineManagement

  8. Connect-ExchangeOnline

This should disappear off to your browser to prompt for authentication.

But that was it, mostly.

Updated on 25/10/2021 following some comments / fixes - thanks!