PowerShell Script to update Page Layout in SharePoint online using PnP

Hi Friends,

I have came across a very common requirement where I need to update the page layout of the SharePoint online page (classic page), but I think same can be used to update the page layout to the modern SharePoint site.


For this I have written a PowerShell script which will update the pages from a specif page layout to the desired page layout. In this script I have also taken care if you are updating the page layout of the subsite, than also this script will handle the scenario.

There are 2 parameters which you need to update
  • Old page layout title
  • New page layout title

The updation due to this script will not change the modified by as well as modified date, so the original data is not lost.

Please provide your comment if you feel that something can be enhanced in the script or if there is any issue


  1. Hi Sumit, I am getting this exception
    Exception happened on getPageLayout : A positional parameter cannot be found that accepts argu
    ment 'ABB ARG Enterprise Wiki'
    ABB ARG Enterprise Wiki : Title of old page layout which i am willing to change

    1. Can you check if the you have got the ctx? This is very generic error and can be due to multiple reasons


Post a Comment

Popular posts from this blog

Rename Folder using Microsoft Flow / Power Automate in a Document Library in SharePoint Online

Power Automate: How to Add "New Line" to the text in SharePoint multiline text field

Power Automate: Rename file in SharePoint Online