SharePoint PnP PowerShell Error : 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.

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."

The term ‘Connect-PnPOnline’ is not recognized as the name of a cmdlet, function, script file, or operable program

How to Solve this Issue

In order to solve this issue, you need to apply one of the following points:

#1: Make sure the module SharePointPnPPowerShellOnline is installed

This case is assuming that the PnP PowerShell Module for SharePoint Online is not Installed on your local machine which will produce the error we are talking about. In order to solve this error, we must install "SharePointPnPPowerShellOnline" module. Here are the steps:
  • Open SharePoint PowerShell as administrator 
  • Run the following command: 
Install-Module SharePointPnPPowerShellOnline
Install-Module SharePointPnPPowerShellOnline

#2: Make sure you don't have multiple versions of this module installed

This error may occur if you have multiple versions of the SharePoint Online PnP PowerShell module installed on your local machine which will create a conflict. In order to check if this case is happening on our local machine, we need to run the following PowerShell command:
Get-Module SharePointPnPPowerShellOnline -ListAvailable | select Name,Version

As you can see in the screenshot, the command returned all versions installed on our local machine. Now, let's see how to solve this issue:
  • 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
After that, if we try to get all installed versions we should see only one version:

I hope this helps!

Post a Comment

Previous Post Next Post