SharePoint Online: Disable Page Comments in Modern Sites using PowerShell

Requirement: Disable page comments in SharePoint Online Modern Sites and Communication sites.
sharepoint online disable page comments

How to Disable Page Comments in SharePoint Online?
Modern pages in SharePoint Online have a comments section at the bottom of each page for better collaboration.

Option 1: Disable Comments at the tenant level
Page comments can be turned-off at tenant level by the below settings:
  • Navigate to SharePoint Online Admin Center: https://yourdomain-admin.sharepoint.com 
  • Click on Settings from left navigation
  • On the Settings page, Select "Disable Comments on Site Pages."
    sharepoint online disable comments
  • Click OK to save your changes.
Wait for a while, the comments section disabled from all pages in the tenant.

Option 2: Disable Comments at the Page Level 
Comments can be disabled at page level. Here is how:
  • Navigate to the SharePoint Online Site page >>  Edit the page.
  • Turn off the comments by toggle the switch from ON to OFF position and Publish the page.
This disables comments section in the particular page.

Option 3: Disable Comments in SharePoint Online Pages using PowerShell
This PowerShell script disables the page comments for given site.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
#Config Parameters
$SiteURL="https://crescent.sharepoint.com/sites/GroupIT"
 
Try {
    #Get Credentials to connect
    $Cred= Get-Credential
 
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
  
    #Get the Web
    $Web = $ctx.Web
    $Ctx.Load($Web)
    $Ctx.ExecuteQuery()

    #Disable Comments in Site Pages
    $Web.CommentsOnSitePagesDisabled = $True
    $Web.Update()
    $Ctx.ExecuteQuery()
    Write-host -f Green "Page Comments has been disabled Successfully!"
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}
Please note, disabling comments doesn't delete existing comments on pages. It just hides them. Turning ON comments brings the comments back!
SharePoint Online: Disable Page Comments in Modern Sites using PowerShell SharePoint Online: Disable Page Comments in Modern Sites using PowerShell Reviewed by Salaudeen Rajack on November 14, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.