Home | How to install PowerShell Modules on MacOS

How to install PowerShell Modules on MacOS

Todays post will teach you how to install PowerShell Modules on MacOS ?

The issue:

This post comes courtesy from our very own Craig Pattison, who has many certs under his belt including, MCSA, MCSE, 365 Security, the list goes on! He is wanting to improve his MacOS knowledge so is using his Mac more and more for work:

Windows users don’t get to have all the fun here. Whilst you can use Bootcamp or virtualization software such as Parallels Desktop as a way to access PowerShell and install the Exchange Online module. These ways take longer as you either have to reboot into Windows or boot into a virtual machine as well as extra Windows licensing costs. There is a quicker way and that is to install PowerShell directly on MacOS and subsequently install the Exchange Online module (or whatever PowerShell module you wish to install).

The resolution:

Pre-Requisites:

Before following the below steps install XCode from the MacOS app store:

Install XCode from App Store

Installing Homebrew

Homebrew is the preferred package manager for MacOS and what I feel is the easiest method to install PowerShell on a Mac.

Open Terminal using either Spotlight search or from the Launchpad > Other menu. If you already have Terminal pinned to your dock you can of course launch it from there too.

Enter /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)” as shown in the following screen and press Enter:

Install Homecrew for MacOS one

You will be prompted for your ‘Sudo’ password which is just the password you have set for your Mac user. Enter this and press Enter:

Install Homebrew for MacOS two

The output will tell you what changes are about to happen. Press Enter to proceed:

Install Homebrew for MacOS three

The command will go off and do its own thing its own thing. Perfect opportunity for a coffee at this point:

Install Homebrew on MacOS four

Once you see a screen like this Homebrew is installed:

Install5

Installing PowerShell

Now that Homebrew is installed you can install PowerShell using the following command:

“brew install –cask powershell”

Install PS on MacOS One

PowerShell will then download as shown below. You are also prompted for your password at this step:

Install PS on MacOS two

PowerShell will then install as shown:

Install PS on MacOS three

Finally, verify that your install is working properly by entering the pwsh command into the Terminal:

Install PS on MacOS four

If you ever need to update PowerShell on your Mac then this can be done via the following two terminal commands: “brew update” and “brew upgrade powershell –cask”

Installing the Exchange Online PowerShell Module.

Now that PowerShell is installed it behaves like any regular PowerShell session on a Windows PC and the usual verb-noun name pairing is used. To install the Exchange Online Powershell Module simply follow these steps:

If you closed Terminal after the above section then re-open it and enter the “pwsh” command to launch a PowerShell session. You will see I am at this point in the screen below:

Install Exchange online module one

Enter “Install-Module ExchangeOnlineManagement” then press Enter, as this is PowerShell the usual pressing of tab to autocomplete a cmdlet applies here:

Install Exchange online module two

Confirm you wish to install the module by entering A for Yes to All:

Install Exchange online module three

Verify the module is installed by running Connect-ExchangeOnline. If pressing tab auto completes this then you know the module has installed successfully:

Install exchange online module on macos four

Optional Steps

If you want to install other PowerShell modules for other areas of Microsoft 365 use the following cmdlets:

AzureAD:

“Install-Module AzureAD”

Install AzureAD module

SharePoint Online:

“Install-Module -Name Microsoft.Online.SharePoint.PowerShell”

Install Sharepoint online module

SharePoint PnP:

“Install-Module -Name SharePointPnPPowerShellOnline”

Install Sharepoint PNP module

Security and Compliance Center

This you have already installed as part of installing the ExchangeOnlineManagement module earlier

Teams:

“Install-Module -Name MicrosoftTeams”

Install Teams module

That’s it! Now you have successfully learned  How to install PowerShell Modules on MacOS, you are now able to manage ExchangeOnline using PowerShell on MacOS!

For more help with anything Exchange Online related or anything else, please feel free to get in touch! ?

Share this post

Facebook
Twitter
LinkedIn