0

We are running PnP PowerShell scripts against SharePoint Online and have had a snag with some of the cmdlets from the PnP library where some of them are not being found (as if they have been removed for the library or it's accessing a previous library than what's listed).

Here's code up to the error:

Connect-PnPOnline -Url $NewSite -Credentials $Credentials  ### Works
Add-PnPSiteCollectionAdmin -Owners @($Owner1, $Owner2)     ### Works
Remove-PnPPage -Identity "Home" -Recycle -Force            ### Errors Out (below)
Add-PnPPage -Name "NewHomePage"

The strange error from Remove-PnPPage (Add-PnPPage will throw same error):

Error: The term 'Remove-PnPPage' 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.

I checked the version we have using Get-Module SharePointPnPPowerShell... and lists only one version, the latest (as of this post).

PS C:\WINDOWS\system32> Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending

Name                          Version    
----                          -------    
SharePointPnPPowerShellOnline 3.29.2101.0

I have Uninstalled the SharePointPnpPowerShellOnline module and then reinstalled it without any luck of working. Any ideas are welcome!

1 Answer 1

1

The module you are using i.e SharepoinPnPPowerShellOnline is a legacy version. Please try to use PnP.Powershell.

Please refer this document for the deprecated and updated commands: https://pnp.github.io/powershell/articles/upgrading.html

1
  • Thank you. Even though this feels like an "obvious" answer to my question, there is a lot of old documentation from the SharePointPnPPowerShellOnline that is out on the Internet that leads to this confusion since some of the cmdlets are used in both libraries.
    – piercove
    Feb 8, 2022 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.