Skip to content

ConvertTo-PnPPage : The term 'ConvertTo-PnPPage' is not recognized as the name of a cmdlet, function, script file, or operable program. #1191

@plee-hele

Description

@plee-hele

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions