PnP PowerShell is a .NET Core 3.1 / .NET Framework 4.6.1 based PowerShell Module providing over 600 cmdlets that work with Microsoft 365 environments and more specifically SharePoint Online and Microsoft Teams. In order to execute any of these commands we must connect to SharePoint site by using 'Connect-PnPOnline' which creates a context that is required for the other PnP Cmdlets. Here is a reference of what you can do with this PowerShell module (PnP PowerShell).
An error may occur if you are try to run this command for the first time:
"Connect-PnPOnline : The term ‘Connect-PnPOnline’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
How to Solve this Issue
#1: Make sure the module SharePointPnPPowerShellOnline is installed
- Open SharePoint PowerShell as administrator
- Run the following command:
Install-Module SharePointPnPPowerShellOnline
#2: Make sure you don't have multiple versions of this module installed
Get-Module SharePointPnPPowerShellOnline -ListAvailable | select Name,Version
- Close all running instances of PowerShell and PowerShell ISE
- Open a new PowerShell window (or SharePoint PowerShell) as Administrator
- Uninstall all installed SharePoint Online PnP PowerShell Modules by running this command:
Uninstall-Module SharePointPnPPowerShellOnline -AllVersions -Confirm:$False
- After removing all versions, we need to install the latest version of the SharePoint Online PnP PowerShell by running this command:
Install-Module SharePointPnPPowerShellOnline