Microsoft 365 – PowerShell script to convert news posts to site page

Hi All,
Greetings.
Today sharing small but important PowerShell script.
PowerShell script – How to convert the news post to site page.
Background:
One of our user wanted to create the content page, but it was mistakenly posted as a news post. Since a news post behaves differently from a content page, the user wants to convert the news post into a content page (site page) instead of deleting it and creating a new page.
So, we came up with the PnP PowerShell approach.
This is two step process.
Type of page / post is identified by its “PromotedState” property. So we need to update the “PromotedState” property of the post.
Detailed Steps:
- Connect to the tenant
- Update the “PromotedState” property of the news post
- “PromotesState” – 2 is for news post
- “PromotesState” – 0 is for site page / content page
- We need to know the ID of the news post which we need to convert to site page

Connect to the tenant
- Here I’ll use Connect-PnPOnline PnP PowerShell CMDLET to connect to my tenant
- I am using
- Client / App ID
- Certificate
Connect-PnPOnline -Url https://knowledgejunction1.sharepoint.com/sites/knowledgejunctiondemo-ClientId $clientid #my client id-CertificatePath $certificatepath #path of my certificate from my local drive -CertificatePassword $certificatepassword #password of my certificate-Tenant 'knowledgejunction1.onmicrosoft.com' #tenant-WarningAction Ignore
Update the “PromotedState” property of the news post
Once we connected successfully to the tenant, we will convert the news post.
We will set “PromotedState” property to 0 (Zero) as
Set-PnPListItem -List "SitePages" -Identity 41 -Values @{"PromotedState"="0"}
As we will execute the above CMDLET, we will see the updated “PromotedState” property.

PS C:\> $certificatepassword = (ConvertTo-SecureString -AsPlainText $certificatepassword -Force)
PS C:\> Connect-PnPOnline -Url https://knowledgejunction1.sharepoint.com
-ClientId $clientid
-CertificatePath $certificatepath
-CertificatePassword $certificatepassword
-Tenant 'knowledgejunction1.onmicrosoft.com'
-WarningAction Ignore
PS C:\> Set-PnPListItem -List "SitePages" -Identity 41
-Values @{"PromotedState"="0"}
Id Title GUID
-- ----- ----
41 Demo - Converting News Post to Content Page b58220ff-94b4-4496-ba8d-b47d5384590e

Thank You 🙂 Have a Great time ahead 🙂

You must be logged in to post a comment.