SharePoint Online - Working With List Settings Using PowerShell

In this article, we will discuss the configuration of some of the important List Settings for SharePoint Online Lists. I have taken only a handful of operations to showcase in this demo, but remember there are a lot more to explore.

Operation: How to enable “New Folder” Menu Command

We can see this setting available under “Advanced Settings” for the list, as shown below.

SharePoint

We can play with this setting using PowerShell as described below.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “EnableFolderCreation” to True.

In Step 3, we will update the list property by calling the “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call a function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see the list setting updated by navigating “Advanced Settings” of the list as shown below.

SharePoint
 
Operation: How to disable “List Item Attachments” Option

We can see this setting available under “Advanced Settings” for the list as shown below.

SharePoint

We can play with this setting using PowerShell as described below.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “EnableAttachments” to False.

In Step 3, we will update the list property by calling the “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call the function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see the list setting updated by navigating “Advanced Settings” of the list, as shown below.

SharePoint
 
Operation: How to enable “Quick Launch” Option for List

We can see this setting available under “General Settings” for the list as shown below.

SharePoint

We can play with this setting using PowerShell, as described below.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “OnQuickLaunch” to True.

In Step 3, we will update the list property by calling “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call the function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see list setting updated by navigating “General Settings” of the list, as shown below.

SharePoint
 
Operation: How to enable “Version History” for List Item Attachments

We can see this setting available under “Versioning Settings” for the list, as shown below.

SharePoint

We can play with this setting using PowerShell as described below.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “EnableVersioning” to True.

In Step 3, we will update the list property by calling “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call the function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see list setting updated by navigating “Versioning Settings” of the list, as shown below.

SharePoint

We may work on additional version settings as well as shown below.

SharePoint

For example, let us try to enable Minor versions for a document library “ProductDesigns” by using PowerShell.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “EnableMinorVersions” to True.

In Step 3, we will update the list property by calling “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call the function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see list setting updated by navigating “Versioning Settings” of the list as shown below.

SharePoint
 
Operation: How to enable “Require Check Out” Option

We can see this setting available under “Versioning Settings” for the list as shown below.

SharePoint

We can play with this setting using PowerShell as described below.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “ForceCheckOut” to True.

In Step 3, we will update the list property by calling “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call the function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see list setting updated by navigating “Versioning Settings” of the list, as shown below.

SharePoint
 
Operation: How to enable “Require Content Approval” Option

We can see this setting available under “Versioning Settings” for the list as shown below.

SharePoint

We can play with this setting using PowerShell as described below.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “EnableModeration” to True.

In Step 3, we will update the list property by calling “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call the function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see list setting updated by navigating “Versioning Settings” of the list as shown below.

SharePoint
 
Operation: How to configure “Draft Item Security” Option

We can see this setting available under “Versioning Settings” for the list as shown below.

SharePoint

We can play with this setting using PowerShell as described below.

SharePoint

In Step 1, we will get the object reference to the respective list by calling “GetByTitle” method.

In Step 2, we will set “DraftVersionVisibility” as “Approver”. This setting will limit access to the draft items for the Approvers only.

In Step 3, we will update the list property by calling the “Update” method.

In Step 4, we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method.

In Step 5, we will display a success message to the Users if Step 4 executes successfully.

In Step 6, we will call a function that we have explained in Step 1-5.

SharePoint

Once this script executes successfully, we can see list setting updated by navigating “Versioning Settings” of the list as shown below.

SharePoint
Code Snippet 
  1. function EnableFolderCreation() {  
  2.     $list = $clientContext.Web.Lists.GetByTitle("Products");  
  3.     $list.EnableFolderCreation = $true;  
  4.     $list.Update();  
  5.     $clientContext.ExecuteQuery();  
  6.     Write - Host - ForegroundColor Green "Folder Creation Enabled"  
  7. }  
  8.   
  9. function ListItemsDisableAttachments() {  
  10.     $list = $clientContext.Web.Lists.GetByTitle("Products");  
  11.     $list.EnableAttachments = $false;  
  12.     $list.Update();  
  13.     $clientContext.ExecuteQuery();  
  14.     Write - Host - ForegroundColor Green "List Items Attachments are disabled"  
  15. }  
  16.   
  17. function EnableQuickLaunch() {  
  18.     $list = $clientContext.Web.Lists.GetByTitle("Products");  
  19.     $list.OnQuickLaunch = $true;  
  20.     $list.Update();  
  21.     $clientContext.ExecuteQuery();  
  22.     Write - Host - ForegroundColor Green "Quick Launch enabled for List Items"  
  23. }  
  24.   
  25. function EnableVersioning() {  
  26.     $list = $clientContext.Web.Lists.GetByTitle("Products");  
  27.     $list.EnableVersioning = $true;  
  28.     $list.Update();  
  29.     $clientContext.ExecuteQuery();  
  30.     Write - Host - ForegroundColor Green "List Versioning Enabled successfully"  
  31. }  
  32.   
  33. function EnableMinorVersions() {  
  34.     $docLib = $clientContext.Web.Lists.GetByTitle("ProductsDocuments");  
  35.     $docLib.EnableMinorVersions = $true;  
  36.     $docLib.Update();  
  37.     $clientContext.ExecuteQuery();  
  38.     Write - Host - ForegroundColor Green "Minor Versions Enabled on List successfully"  
  39. }  
  40.   
  41. function ForceCheckOut() {  
  42.     $docLib = $clientContext.Web.Lists.GetByTitle("ProductsDocuments");  
  43.     $docLib.ForceCheckOut = $true;  
  44.     $docLib.Update();  
  45.     $clientContext.ExecuteQuery();  
  46.     Write - Host - ForegroundColor Green "Force Checkout Enabled"  
  47. }  
  48.   
  49. function EnableContentApproval() {  
  50.     $docLib = $clientContext.Web.Lists.GetByTitle("ProductsDocuments");  
  51.     $docLib.EnableModeration = $true;  
  52.     $docLib.Update();  
  53.     $clientContext.ExecuteQuery();  
  54.     Write - Host - ForegroundColor Green "Content Approval Enabled"  
  55. }  
  56.   
  57. function GrantPermissionOnMinorAndDrafts() {  
  58.     $docLib = $clientContext.Web.Lists.GetByTitle("ProductsDocuments");  
  59.     $docLib.DraftVersionVisibility = [Microsoft.SharePoint.Client.DraftVisibilityType]::Approver;  
  60.     $docLib.Update();  
  61.     $clientContext.ExecuteQuery();  
  62.     Write - Host - ForegroundColor Green "Permission Granted"  
  63. }  
That is all for this demo.

I hope you find it helpful.