In modern SharePoint site, comments are shown at the bottom of modern site pages where user can add feedback related to the content on the page. Comments can be disabled at the tenant level for all the sites or a page editor can also enable/disable comments on a page by simply edit the page.

Delete comments from Site Pages library

Users can submit comments on a SharePoint modern page but there is no option for users site owners and submitter to delete or modify the comment.

Page owner can delete this by going to page details and select the three dots to delete all comments on the page as shown in the picture.

PowerShell to delete comments

I have written a small PowerShell cmdlet to delete comments from a page using PnP PowerShell module.

$listName= "Site Pages" 
$itemID = "5"
$comments = Get-PnPListItemComment -List $listName -Identity $itemID

        foreach($comment in $comments)
        {            
               Remove-PnPListItemComment -List $listName -Identity $itemID -Text $comment.Text -Force               
            
        }

Adnan Amin is a Microsoft MVP for Microsoft 365 (since 2015) and a Senior Microsoft Consultant. He writes practical guides and PowerShell scripts for SharePoint, OneDrive, Teams and Copilot admins.

Leave a Reply

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