How To Run PnP PowerShell In MacOS


There may be requirements where we need to use PowerShell and if we are using macOS then the question becomes how we can use PowerShell in macOS. But with Microsoft’s new approach of creating everything open source and cross-platform, we can achieve this very easily. But along with this, we would even have a look at how we can use cross-platform PnP PowerShell to automate our Microsoft 365 related tasks.

To run PowerShell Script in Mac OS follow the below steps,

Step 1 - Install Homebrew

To run PowerShell we need to have Homebrew; it is a package manager which is used for installing packages that are missing in macOS.

Use the below command in the terminal to install Homebrew,

/bin/bash -c "$(curl -fsSL"

Step 2 - Install PowerShell

Once we have to install Homebrew now we are good to install PowerShell. This is also recommended by Microsoft for more details check the link.

Use the below command to install PowerShell,

    brew cask install powershell

To test if we have installed properly or not use the below command,


Now let us walk through step by step process of using PnP.PowerShell is a cross-platform module for working with Microsoft 365 related activities.

Step 1 - Register the package source

This step is required because we would like to add PowerShell salary as the package source provider so that we can install the module directly without an issue to do so run the below command,

Register-PackageSource -Name PSNuGet -Location -ProviderName NuGet

Now we have set the package source so that we can search for our required PnP.PowerShell module which we can use for our Microsoft 365 related PowerShell activities.

Step 2 - Install PnP PowerShell

Now to work with PnP PowerShell we need to install dependencies for that we would require to run the below command,

Install-Module PnP.PowerShell

Now we are ready to use PnP PowerShell let us test that by connecting to any site collection.

Step 3 - Connect to SharePoint and get the web

To connect to SharePoint we can use the Connect-PnPOnline command and we can even use web login or device login if in case you are using Multi-factor authentication.

Connect-PnPOnline -Url

To get the web once we have logged in we can just use Get-PnPWeb which would provide us the web to the URL we have logged in using connect cmdlet.



With the help of PowerShell being cross-platform, we can use any operating system of our choice to leverage PowerShell and the best part is, it is even available in docker image as well.

The previous version of PnP PowerShell, which was SharePointPnPPowerShellOnline, was not cross-platform, but thanks to CSOM for .net core has helped us with the new Module PnP.PowerShell which is now cross-platform so we can leverage it to automate our tasks irrespective of the operating system we are working with.