Add And Manipulate Modern SharePoint Page Using PnP PowerShell

In this blog, we will look at the steps to 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

This solution is brought to you by our SharePoint professionals.

Softree Technology employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.

Be it SPFx or SharePoint add-in developments, SharePoint 2019 developments, web part developments, migrating from SharePoint 2010/2013 to SharePoint 2013/2016/Office 365, Office 365, SharePoint hosted apps development or something else in SharePoint, we strive to deliver the best

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *