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.”
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
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
I am having the same issue today as Subi. Any ideas??
Hi Will, found any resolution please?
Hi Subi, Can you try this fix: https://www.sharepointdiary.com/2021/04/connect-pnponline-command-was-found-in-module-pnp-powershell-but-module-could-not-be-loaded.html
Hi Salaudeen
Thanks. Tried that and getting the following error:
PS C:\Windows\System32> Import-Module PnP.PowerShell
Import-Module: Could not load file or assembly ‘System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. The system cannot find the file specified.
PS C:\Windows\System32> $PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
—– —– —– ————— ———-
7 0 2
PS C:\Windows\System32>
Hi
I’m getting the following error on a PS script that was working fine before in “Pnp.Powershell v1.12.0” libraries.
Error: The ‘Connect-PnPOnline’ command was found in the module ‘PnP.PowerShell’, but the module could not be loaded. For more information, run ‘Import-Module PnP.PowerShell’.
I update it to “v2.1.1” and getting the above error. The same script works with v1.12.0 (on a different node)
Any idea please?
Thanks
Subi