Bulk creation of Publishing Pages using PowerShell CSOM







In this post, we will look how to create publishing pages in bulk using the PowerShell CSOM. A CSV file will be used as an input which holds the meta data details of the page to be created. I have created a simple CSV file with the below columns matching my page layouts fields. For simplicity and time saving I just created two rows which means just two pages. (You said bulk :-) ) I'm using plain text for the Publishing Page Content column, I think it should be fine with the html code too.



SEE ALSO - Replacing YouTube, Vimeo, Vine Urls with embed code in pages. 












I'll be using the below PowerShell CSOM code for this activity, which will read the rows in the CSV and create the corresponding publishing page. First loading the appropriate page layout from the catalogs folder.





Creating the publishing page


DOWNLOAD - Complete PowerShell file from here 



The code is self explanatory so I'm not going line by line. Make sure to update the site url, page layout name inside the CAML query and other appropriate values. You can even have the page layout information inside the CSV file and use it for the page creation, in that case make sure to bring the page layout loading piece inside the for loop.





Comments