Invoke Power Shell: "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"

Invoke Power Shell: 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.

Issue Description: Invoke Power Shell: 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. Edit Error Message

Resolution:

  1. Check if the following module is installed
  • Get-module -ListAvailable

This gets all installed modules in the system along with their installed Path. Get the path of the custom module as highlighted. In my case, the PnP PowerShell module was installed at “C:\Program Files\WindowsPowerShell\Modules”.

  1. Verify if the custom module’s path is added to the “PSModulePath”

As the next step, verify if the custom module’s path is added to the “PSModulePath” variable.

  1. Go to System Properties by pressing Windows Key + Pause Break (Or Go to File Explorer >> Right click on “This PC” >> Properties) >> Click on Advanced System Settings >> Click on Environment Variables
  2. Pick “PSModulePath” and click on “Edit” button.
  1. Append the PowerShell Module path to this variable. In this case, it is “C:\Program Files\WindowsPowerShell\Modules”, separated by ; (semicolon). From Windows 10 onwards, there is a neat option available to add new path. Hit “New” button and add the module’s path there.
  1. Restart PowerShell ISE or PowerShell console.

Possible errors:

If the above does not resolve the issue, try installing using the below commands:

  • Install-Module -Name SharePointPnPPowerShellOnline

If below error like this appears:

Use the next command:

  • Install-Module -Name SharePointPnPPowerShellOnline -AllowClobber

This skips the error.

Then, send again the command

  • Get-module -ListAvailable

To see if the SharePoint module is installed successfully.

This works with all the PowerShell modules.