SharePoint PnP logo

How to solve errors about missing PnP Cmdlets on PowerShell

This post was most recently updated on November 25th, 2018.

Reading Time: 3 minutes.

This blog posts 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 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 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!
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

Antti K. Koskela

Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world.

He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff.

This is his personal professional (e.g. professional, but definitely personal) blog.

Leave a Reply

avatar
5000
  Subscribe  
Notify of