ConvertTo-PnPPage : The term 'ConvertTo-PnPPage' is not recognized as the name of a cmdlet, function, script file, or operable program.
Currently using SharePoint Online for office 365. Promoted classic sites from SharePoint online to modern sites using Sharegate tool, same tenant. The sites, libraries and lists all converted fine. All pages remained in classic version. Trying to run script to convert them but cannot get past the message 'ConvertTo-PnPPage' is not recognized.
(PnP install script) "Install-Module -Name PnP.PowerShell"
Connect-PnPOnline -Url https://mycompany.sharepoint.com -UseWebLogin (Connects good)
(Run this script)
#Set Parameters $SiteURL="https://mycompany.sharepoint.com/sites/sitename"
#Connect to Site Connect-PnPOnline -Url $siteUrl -UseWebLogin
#Get All Pages from "Site Pages" Library $Pages = Get-PnPListItem -List SitePages -PageSize 500
Try { ForEach($Page in $Pages) { #Get the page name $PageName = $Page.FieldValues.FileLeafRef Write-host "Converting Page:"$PageName
#Check if the page is classic
If($Page.FieldValues["ClientSideApplicationId"] -eq "b6917cb1-93a0-4b97-a84d-7cf49975d4ec")
{
Write-host "`tPage is already Modern:"$PageName -f Yellow
}
Else
{
#Conver the classic page to modern page
ConvertTo-PnPPage -Identity $PageName -Overwrite -TakeSourcePageName -AddPageAcceptBanner
Write-host "`tPage Converted to Modern!" -f Green
}
}
} Catch { write-host -f Red "Error Converting Clasic Page to Modern!" $_.Exception.Message }
(receive this message)
Error Converting Clasic Page to Modern! The term 'ConvertTo-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.
Sounds like the issue is related to PnP.PowerShell rather than PnP Framework.
But if you're able to use the -UseWebLogin switch, you're not on the latest version, so my suggestion would be to try and update, your installation of PnP.PowerShell, and if that doesn't solve it, I would try to create the issue in their repo PnP.PowerShell
Okay, thank you. I've tried uninstalling all versions and then reinstalling multiple times. If I don't use -UseWebLogin to connect, I'm not able to sign in and authenticate. We use MFA and the only way to authenticate was to use -UseWebLogin. I have no options to disable MFA per our company policies.
@plee-hele Please see the getting started guide for PnP PowerShell, since version 3 you need to BYOAR (Bring Your Own App Registration)
https://pnp.github.io/powershell/articles/registerapplication.html
Thank you, very helpful. Facing a new issue with error when trying to re-install the PnP.PowerShell. I will open another issue for that. Appreciate your help.