Enable/Disable SharePoint Online List Comments using CLI for Microsoft 365
SharePoint Online lists are a great way to organize and manage data within your organization. They provide a flexible and customizable platform for teams to collaborate and share information. One of the features available in SharePoint Online lists / Microsoft Lists is the ability to add comments to list items. This can be a useful way to provide feedback, ask questions, or share information related to specific items within the list.
However, there may be situations where you want to disable comments for a particular list. This could be because you want to limit the amount of noise or clutter in the comments section, or because you want to encourage users to provide feedback in a different way.
In this blog post, we will walk through the steps required to enable or disable comments for a SharePoint Online list using the CLI for Microsoft 365.
Step 1: Install the CLI for Microsoft 365
Before we can start working with the CLI for Microsoft 365, we need to install it. You can install the CLI for Microsoft 365 by using below NPM commands or by following the instructions on the official documentation page: CLI for Microsoft 365 – Installation. You have to install CLI for M365 v6.7.0 (beta) or higher.
npm install -g @pnp/cli-microsoft365
You have to use below command if you want to install beta version of CLI for Microsoft 365:
npm install -g @pnp/cli-microsoft365@next
Step 2: Enable or Disable Comments for a SharePoint Online List
To enable or disable comments for a SharePoint Online list, we have to use the m365 spo list set command in the CLI for Microsoft 365. The syntax for this command is as follows:
m365 spo list set --webUrl <site url> --title <list title> --disableCommenting <true/false>
Let’s break down each of these parameters:
--webUrl: The URL of the SharePoint Online site where the list is located.--title: The title of the list you want to enable or disable comments for.--disableCommenting: Set this totrueto disable comments, orfalseto enable comments.
Here’s a complete CLI for Microsoft 365 script which you can use to disable comments for a SharePoint Online/Microsoft Lists modern experience list:
# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"
# Display name of SharePoint list
$listName = "Comments List"
# Get Credentials to connect to SharePoint site
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
m365 login
}
# Disable SharePoint online list comments
m365 spo list set --webUrl $siteUrl --title $listName --disableCommenting true
You can modify this CLI for M365 script to enable SharePoint list comments by changing the --disableCommenting parameter to false.
Once you run above script successfully, navigate to List Settings > Advanced Settings and you will find that commenting is disabled for your SharePoint online list:

Learn more
- Enable/Disable the comments for a SharePoint Online/Microsoft List
- Enable/Disable SharePoint Online List Comments using PnP PowerShell
- Enable/Disable SharePoint Online List Comments using SharePoint REST API
- How to Enable/Disable the commenting in all SharePoint Online/Microsoft Lists – tenant level
- SharePoint Online: Apply JSON View formatting using CLI for Microsoft 365
- How to find the Internal name of columns in SharePoint Online using CLI for Microsoft 365?