How to solve errors about missing PnP Cmdlets on PowerShell

SharePoint PnP logo

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!  Continue reading

Fixing the “For security reasons DTD is prohibited in this XML document.” issue

"For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method."

This post describes a couple of ways to fix the issue “For security reasons DTD is prohibited in this XML document”. At least for me, it appeared when trying to access SharePoint Online using Powershell or a console program using OfficeDev.PnP (which in turn uses CSOM).

Error

When running any piece of code, whether in PowerShell, .exe console or anything else than in the code behind relies on .NET Framework, you get an error like this:

For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method.

Continue reading