In this PnP tutorial, we will discuss how to fix an error which says, Connect-PnPOnline : The term ‘Connect-PnPOnline’ is not recognized as the name of a cmdlet, function, script file, or operable program.
The error comes when I was trying to connect to a SharePoint Online Office 365 site by using the Connect-PnPOnline PnP PowerShell cmdlets.
Connect-PnPOnline -Url 'https://tsinfo.sharepoint.com/sites/SPFxTraining/' -Credentials (Get-Credential)
The full error comes as:
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.
At line:1 char:1
- Connect-PnPOnline -Url ‘https://tsinfo.sharepoint.com/sites/SPFxTrain …
~~~~~- CategoryInfo : ObjectNotFound: (Connect-PnPOnline:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
You may also get few errors like below:
Get-PnPList : The term ‘Get-PnPList’ 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.
Get-PnPField : The term ‘Get-PnPField’ 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
To fix the error, either Open PowerShell command prompt or PowerShell ISE and run the below command.
Install-Module SharePointPnPPowerShellOnline
Once you run the command, It will ask for a confirmation message.
You are installing the modules from an untrusted repository……..
Click on Yes to All like below:
Then you can see it will install the SharePointPnPPowerShellOnline package like below:
Now, when you run the Connect-PnPOnline, Get-PnPList or Get-PnPField cmdlets, you will not get any error.
You may like the following PnP PowerShell tutorials:
- Create a managed property in SharePoint Online/2013/2016
- How to use SharePoint Online Management Shell
- How to get access token in SharePoint Online using CSOM and use in Postman or Google Rest client
- Get SharePoint List Name and GUID using PowerShell and CSOM
- Delete and restore SharePoint site or subsite using Browser and PowerShell
In this tutorial, we learned how to fix error, connect-pnponline is not recognized.
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Out audiences are from the United States, Canada, United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a SharePoint MVP(8 times), check out My MVP Profile. I have also worked in companies like HP, TCS, KPIT, etc.
21st of November 2022
WARNING:
You are running the legacy version of PnP PowerShell.
This version will be archived soon which means that while staying available, no updates or fixes will be released.
Consider installing the newer prereleased cross-platform version of PnP PowerShell.
This version has numerous improvements and many more cmdlets available.
To install the new version:
Uninstall-Module -Name SharePointPnPPowerShellOnline -AllVersions -Force
Install-Module -Name PnP.PowerShell