Convert classic home page to modern home page

Harish Patil 21 Reputation points
2021-04-01T18:08:51.887+00:00

Hi Team,

I am trying below code to convert classic page to modern page. But getting below error.

Kindly suggest the resolution for the same.

Code:

$modernPage = ConvertTo-PnPClientSidePage -Identity $page.FieldValues["FileLeafRef"] -Overwrite

Error: The 'ConvertTo-PnPClientSidePage' command was found in the module 'SharePointPnPPowerShellOnline', but the module could not be loaded. Fo
r more information, run 'Import-Module SharePointPnPPowerShellOnline'.

Thanks,

Harish Patil

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,560 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Elsie Lu_MSFT 9,756 Reputation points
    2021-04-02T07:42:12.48+00:00

    Hi @Harish Patil ,

    Per my test, you could follow these steps:
    Download SharePoint online management shell

    Then run the command:

    Install-Module SharePointPnPPowerShellOnline  
    

    And connect your site:

    #Connect to the classic site with pages to modernize    
    Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/teamsite    
    

    Like this:
    83936-1.jpg

    Then run this command, you will see a new modern page, and then set it to Home page:

    ConvertTo-PnPClientSidePage -Identity Home.aspx -AddPageAcceptBanner    
    

    83972-2.jpg

    Reference:
    Transform Classic SharePoint Pages To Modern Look And Feel

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Uko Tan 1 Reputation point
    2021-04-02T19:14:43.707+00:00

    I would validate the pnp module already loaded. Are you running a compatible version of PNP powershell with respect to the native powershell modules?

    PS> get-module | fl *

    Try reloading the PNP powershell directly from nuget

    PS> Install-PackageProvider Nuget -force
    PS> Update-Module -Name PowerShellGet -Force
    PS> Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
    PS> Install-Module SharePointPnpPowerShellOnline

    HTH

    0 comments No comments