The PnP PowerShell module, developed by Microsoft’s Patterns and Practices (PnP), has evolved into an essential resource for SharePoint administrators and developers. Offering a comprehensive array of PowerShell cmdlets for SharePoint and SharePoint PowerShell.

I was using an older version of PnP module in an old VM, i need to update the PnP module on that machine, so decided to write this blog post to update the steps with you. Here I am going to share the steps install and update your PnP PowerShell module and will also go through with some basic cmdlets to verify the connectivity.

Require / Recommended Software Modules:

You will need PowerShell 7 for using PnP PowerShell. I would also recommend to install Visual Studio code for working on PowerShell scripts.

Step By Step Installation for PnP PowerShell Module

PowerShell 7

Make sure already have PowerShell 7 installed on the machine, if not than go to Installing PowerShell on Windows – PowerShell | Microsoft Learn and install the PowerShell 7 Package.

PnP PowerShell Installation

Follow below steps for installation for PnP PowerShell module for SharePoint online:

  1. Open the PowerShell 7 as administrator
  • You need to check for any existing legacy SharePoint PnP PowerShell module and need to uninstall them. Run below cmdlet to get list of any existing PnP PowerShell module:
Get-Module SharePointPnPPowerShellOnline -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending
  • Run below cmdlet to uninstall the existing legacy PnP PowerShell modules:
Uninstall-Module SharePointPnPPowerShellOnline -Force -AllVersion
  • Now we are all set to start the installation for PnP PowerShell module. Run below cmdlet for installation:
Install-Module PnP.PowerShell
  • Press Yes for installation. This will download and install the PnP PowerShell module from the PowerShell Gallery on your machine. We are set for the installation of PnP module.

Register and Grant Access to the tenant

Now register a new Azure AD Application and grant access to the tenant to the PnP Management Shell Multi-Tenant Azure AD Application. This would be required whenever you going to write and test a PowerShell script for any new Tenant and need to provide permissions to the login user. Use below cmdlet to register for registration to Azure AD Application:

Register-PnPManagementShellAccess

This will prompt to log in and provide consent for your tenant. Use global admin account to complete the step.

After sign-in, you will be prompted to accept the permissions required for PnP Management Shell. Check on the “Consent on behalf of your organization” checkbox and hit accept button.

Verify Installation

Now we are good with the installation, you can now test the installation by running some basic cmdlets.

Connect to a SharePoint site

Use below cmdlet to connect to connect to a SharePoint online site, this will prompt you for login

Connect-PnPOnline -Url "https://constos.sharepoint.com" -Interactive

The above cmdlet will assure that you are well connected with PnP PowerShell, and now you can start running your scripts.

Update PnP PowerShell

Just like the installation, Updating PnP PowerShell for SharePoint is also a simple process. Open PowerShell 7 as administrator user and run below cmdlet:

Update-Module -Name "PnP.PowerShell"

Check version of PnP PowerShell

Get-InstalledModule -Name "PnP.PowerShell"

Uninstall the PnP PowerShell

If you are looking to uninstall the PnP PowerShell, use below cmdlet for uninstallation:

Uninstall-Module -Name "PnP.PowerShell"

Adnan, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply