Retrieve Modern Pages From SharePoint Library Using PnP PowerShell

In this blog, we are going to see how to retrieve modern pages from the SharePoint library using PnP PowerShell.

Each page type is associated to different content types as shown in the below table.
  • Wiki Page - 0x0101080046AF17D81F507844AF17A75863CF8B6B
  • WebPart Page - 0x0101090100377FC055EC56F44093458B25AB81B73D
  • SitePage - 0x0101009D1CB255DA76424F860D91F20E6C411800E53BD99D3E0D8545813DF21536D1B228
Here, we are going to use the SitePage Content Type Id to filter the modern pages from the library from SharePoint web.

The below PnP PowerShell command with CAML query is used to retrieve the modern pages from the SharePoint library.
  1. PS:> $cred = Get-Credential  
  2. PS:> Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/dev -Credential $cred  
  3. PS:> Get-PnPListItem -List "Site Pages" -Query "<View><Query><Where><Eq><FieldRef Name='ContentTypeId'/><Value Type='Text'>0x0101009D1CB255DA76424F860D91F20E6C411800E53BD99D3E0D8545813DF21536D1B228</Value></Eq></Where></Query></View>"  
 
Ebook Download
View all
Learn
View all