SharePoint PnP logo

How to solve errors about missing PnP Cmdlets on PowerShell

This post was most recently updated on October 4th, 2022.

2 min read.

This blog post briefly describes how to solve some of the most typical errors about missing PnP Cmdlets when using Windows Powershell (or SharePoint Online Management Shell).

Symptoms

When trying to run some PnP-related cmdlet, you get an error similar to the ones below:

Connect-PnPOnline : The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or o
perable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try aga
in.
At C:\Users\koskela\Downloads\Import-Valo-With-Content\Import\New-Valo.ps1:46 char:5
+     Connect-PnPOnline -Url $AdminUrl
+     ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Connect-PnPOnline:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Get-PnPTenantSite : The term 'Get-PnPTenantSite' is not recognized as the name of a cmdlet, function, script file, or o
perable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try aga
in.
At C:\Users\koskela\Downloads\Import-Valo-With-Content\Import\New-Valo.ps1:51 char:23
+     $SiteCollection = Get-PnPTenantSite -Url $Url -ErrorAction Silent ...
+                       ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-PnPTenantSite:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
New-PnPTenantSite : The term 'New-PnPTenantSite' is not recognized as the name of a cmdlet, function, script file, or o
perable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try aga
in.
At C:\Users\koskela\Downloads\Import-Valo-With-Content\Import\New-Valo.ps1:60 char:7
+       New-PnPTenantSite -Title $Configuration.SiteCollection.Title `
+       ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-PnPTenantSite:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Usually, this is luckily a simple fix! 

Reason

Usually, it’s simple enough. You don’t have the cmdlets installed, or sometimes you might have multiple, conflicting ones. Let’s get rid of the old ones, and just go with the latest one!

In the examples below, “SharePointPnPPowerShellOnline” refers to the SharePoint Online version of the PnP commandlets, but you can replace “Online” in the module name with “2013”, “2016” or “2019” to use a different SharePoint Server (On-Premises) versions of the commandlets instead!

In any case, the code below will go through your modules and show you, which versions you might have. See the example output below as well:

Get-Module SharePointPnpPowerShellOnline -ListAvailable | select Name,Version
Output of the PowerShell commandlet "Get-Module SharePointPnpPowerShellOnline -ListAvailable | select Name,Version" on my machine. I had a couple of different SharePointPnPPowerShellOnline commandlets installed!
The output of the PowerShell commandlet “Get-Module SharePointPnpPowerShellOnline -ListAvailable | select Name, Version” on my machine. I had a couple of different SharePointPnPPowerShellOnline commandlets installed!

If you’ve got a few, get rid of them with this before continuing with the solution:

Remove-Module -name SharePointPnPPowerShellOnline

Solution: (re)install the PnP-cmdlets

This usually fixes any basic, run-of-the-mill issues with these commandlets. It’s often a good idea to rule out the version conflicts or old versions of the commandlets before trying to figure it anything else. Run the following:

Install-Module SharePointPnPPowerShellOnline

This works in Windows 10, or if you have PowerShellGet installed.

For more information, check this page out: https://github.com/SharePoint/PnP-PowerShell

mm
2.5 2 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments