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.

Problem: When trying to run a PowerShell script for SharePoint Online, I got this error message:
“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.”

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

This error message typically indicates that the PowerShell cmdlet or module that you are trying to use is not installed or is not in the current session’s PATH. To resolve this issue, you can try the following:

Case 1: PnP PowerShell Module is not Installed

Usually, this error occurs when you don’t have the PnP PowerShell module for SharePoint Online is installed on the local machine. So, to get rid of this error, you must install the “PnP.PowerShell” module as:

Install-Module PnP.PowerShell

More information on installing the PnP PowerShell module for SharePoint Online is here: How to Install PnP PowerShell Module for SharePoint Online?

Case 2: Multiple Versions of the PnP PowerShell Modules are installed, and there is a Conflict!

In some cases, this error could be because of multiple versions of the SharePoint Online PnP PowerShell module installed and conflicting! Close all running instances of PowerShell and PowerShell ISE, Open a new PowerShell window as Administrator, and run these steps:

  • Step 1: Get All Installed versions of classic SharePoint Online PnP PowerShell
  • Step 2: Uninstall All Installed SharePoint Online PnP PowerShell Modules
    Uninstall-Module SharePointPnPPowerShellOnline -AllVersions -Confirm:$False      
  • Step 3: Install the latest versions of SharePoint Online PnP PowerShell
    Install-Module PnP.PowerShell
The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or operable program

In general, You have to make sure that the module containing the cmdlet is installed on your system by running the command Get-Module -ListAvailable and checking if the module is in the list. If the module is not installed, you can install it using the Install-Module command. Here are some similar error messages you may get with other cmdlets.

If you are getting “The term ‘connect-pnponline’ is not recognized as the name of a cmdlet” error in the Azure function, make sure you are importing the PnP PowerShell module in Windows PowerShell compatibility: Import-Module -Name PnP.Powershell -UseWindowsPowerShell

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *