1

I am working on a SharePoint online classic team site. and from time to time I run these remote power-shell commands:-

1- To un-post a modern page from being shown as News:-

$clientSidePage = Get-PnPClientSidePage -Identity "TEST-PAGE.aspx"
$clientSidePage.DemoteNewsArticle()

2- To disable comments on a modern page:-

$cred = Get-Credential  
Connect-PnPOnline -Url hhttps://*.sharepoint.com/ -Credential $cred  
Set-PnPClientSidePage -Identity "test-page.aspx" -CommentsEnabled:$false

now the first command will cause the ModifiedBy + the Modified fields to be updated. where the second command will cause the ModifiedBy field to be updated. also both commands will cause users' alerts to be sent (when users set the alert on every change).

so can i modify my above 2 commands, so the ModifiedBy and the Modified fields will not get updated? also to prevent users' alerts from being sent?

Thanks

1

1) To un-post the Modern page from being shown as News without changing the modified and modifiedby fields, you can do as below:

$clientSidePage = Get-PnPClientSidePage -Identity "TEST-PAGE.aspx"

Set-PnPListItem -List "Site Pages" -Identity $clientSidePage.PageListItem.Id 
-Values @{"PromotedState"=0} -SystemUpdate

Basically, we are setting the property PromotedState to 0 and updating it using SystemUpdate method.

2) To disable comments, you can do so as below:

$clientSidePage = Get-PnPClientSidePage -Identity "TEST-PAGE.aspx"

$listItem = $clientSidePage.PageListItem;

$listItem.SetCommentsDisabled($true)

$listItem.SystemUpdate()

Invoke-PnPQuery
  • looks like it is working 100% .. thanks a lot. also no users' alerts are been sent which is great.. – SharePoint TestDev Nov 6 '18 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.