Add And Manipulate Modern SharePoint Page Using PnP PowerShell

Adding a Modern page to the SharePoint site

The Add-PnPClientSidePage command is used to add a modern page to the SharePoint site.

  • Add-PnPClientSidePage -Name "NewPage"
Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Output

Add and Manipulate Modern SharePoint Page Using PnP PowerShell

By default, Add-PnPClientSidePage creates an Article layout type. To create the Home layout type, we have to pass "Home" as a “LayoutType” parameter.

  • Add-PnPClientSidePage -Name "NewPage" -LayoutType Home
Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Output

Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Set the Modern page Property

The Set-PnPClientSidePage command is used to update the property of a SharePoint Modern page.

Example 1

This example updates the properties of the modern page named "MyPage".

  • Set-PnPClientSidePage -Identity "NewPage" -Title "MyPage"
Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Output

Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Example 2

This example disables the comments on the Modern page.

  • Set-PnPClientSidePage -Identity "NewPage" -CommentsEnabled:$false
Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Output

Add and Manipulate Modern SharePoint Page Using PnP PowerShell
 

Example 3

This example enables the comments on the Modern page.

  • Set-PnPClientSidePage -Identity "NewPage" –CommentsEnabled
Add and Manipulate Modern SharePoint Page Using PnP PowerShell
 
Output
Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Getting the Modern page information

The Get-PnPClientSidePage command is used to get information about the SharePoint Modern page.

  • Get-PnPClientSidePage -Identity " NewPage"
Add and Manipulate Modern SharePoint Page Using PnP PowerShell

Removing a Modern page from the SharePoint site

The Remove-PnPClientSidePage command is used to remove the specified modern page from the SharePoint site collection.

  • Remove-PnPClientSidePage -Identity "NewPage"
Add and Manipulate Modern SharePoint Page Using PnP PowerShell