PnP PowerShell is the most widely used module for managing SharePoint Online and Microsoft 365 from the command line. Before you start, one thing matters: current versions run on PowerShell 7 only. Windows PowerShell 5.1, which ships with Windows, is no longer supported.
Installing PowerShell 7
If you don’t have PowerShell 7 yet, install it with winget:
winget install --id Microsoft.PowerShell --source wingetThen open a new PowerShell 7 window (not Windows PowerShell) and check the version:
$PSVersionTable.PSVersionInstalling the module
Install for your own account, no administrator rights needed:
Install-Module PnP.PowerShell -Scope CurrentUserIf you want the very latest development build there is a nightly release. Use it for testing only, not in production:
Install-Module PnP.PowerShell -AllowPrerelease -Scope CurrentUserWhich version am I running?
The version currently loaded:
Get-Module PnP.PowerShell | Select-Object Name, VersionEvery version installed on your machine, loaded or not:
Get-Module PnP.PowerShell -ListAvailable | Select-Object Name, Version, PathMore than one version listed? PowerShell will usually load the newest, but that pile-up is the most common cause of unexplained errors. See our guide on cleaning up modules.
Updating
Update-Module PnP.PowerShellNote: Update-Module installs the new version alongside the old one and does not remove it. So clean up periodically.
What next?
Installing is not enough to connect. Since September 2024 you need your own Entra app registration. Continue with the guide on registering an Entra app.
Frequent errors and how to fix them
These are the messages people type into search when the module will not start. The exact wording is here so this page can be found.
The term 'Connect-PnPOnline' is not recognized- The module is not loaded. Install on PowerShell 7 (not 5.1), close the window, then Import-Module PnP.PowerShell.
AADSTS700016 / Application not found- The Entra app is missing or the Application (client) ID is wrong. Register your own app (required since 2024).
AADSTS65001 / consent- Admin consent is missing. In Entra: the app → API permissions → Grant admin consent.
not compatible with Windows PowerShell 5.1- Current PnP.PowerShell runs on PowerShell 7 only. Use pwsh, not powershell.exe.
PnP Management Shell / multi-tenant app retired- Since 9 Sep 2024 you must register your own Entra app. Register-PnPEntraIDApp or create it in Entra.
Access denied / Attempted to perform an unauthorized operation- The app is missing Graph or SharePoint scopes, or Sites.Selected is not granted on this site.
Please specify a valid client id for an Entra ID App Registration- Since 9 September 2024, Connect-PnPOnline only connects with your own Entra ID app. Register it once with
Register-PnPEntraIDAppForInteractiveLoginand connect with-ClientId. You get the same message with an empty client ID or an app from another tenant. Step by step. Assembly with the same name already loaded- Multiple PnP.PowerShell versions. Uninstall-Module PnP.PowerShell -AllVersions, then one version, new window.
Questions about this, or need help setting it up? We are happy to think along.
Message on LinkedIn →