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:
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:
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:
The output will tell you what changes are about to happen. Press Enter to proceed:
The command will go off and do its own thing its own thing. Perfect opportunity for a coffee at this point:
Once you see a screen like this Homebrew is installed:
Installing PowerShell
Now that Homebrew is installed you can install PowerShell using the following command:
“brew install –cask powershell”
PowerShell will then download as shown below. You are also prompted for your password at this step:
PowerShell will then install as shown:
Finally, verify that your install is working properly by entering the pwsh command into the Terminal:
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:
Enter “Install-Module ExchangeOnlineManagement” then press Enter, as this is PowerShell the usual pressing of tab to autocomplete a cmdlet applies here:
Confirm you wish to install the module by entering A for Yes to All:
Verify the module is installed by running Connect-ExchangeOnline. If pressing tab auto completes this then you know the module has installed successfully:
Optional Steps
If you want to install other PowerShell modules for other areas of Microsoft 365 use the following cmdlets:
AzureAD:
“Install-Module AzureAD”
SharePoint Online:
“Install-Module -Name Microsoft.Online.SharePoint.PowerShell”
SharePoint PnP:
“Install-Module -Name SharePointPnPPowerShellOnline”
Security and Compliance Center
This you have already installed as part of installing the ExchangeOnlineManagement module earlier
Teams:
“Install-Module -Name MicrosoftTeams”
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! ?