SharePoint Online: Configure List Settings using PowerShell
Requirement: Edit List Settings in SharePoint Online using PowerShell
How to Change List Settings in SharePoint Online?
List settings in SharePoint Online define the attributes of the list such as Name, description, etc and functionality of the lists. These settings can be configured by navigating to the list settings page. To manage these settings, do the following:
SharePoint Online: PowerShell to Set List Settings
Here is the PowerShell to update most common properties of a SharePoint Online list or library.
PnP PowerShell to Change List Settings in SharePoint Online:
To configure list settiings, we can use these PnP PowerShell scripts as well.
My other posts on configuring List settings in SharePoint Online using PowerShell:
Here is my another article to get SharePoint Online List Settings: SharePoint Online: PowerShell to Get List Settings
How to Change List Settings in SharePoint Online?
List settings in SharePoint Online define the attributes of the list such as Name, description, etc and functionality of the lists. These settings can be configured by navigating to the list settings page. To manage these settings, do the following:
- Navigate to the list or library Settings page from Settings >> List Settings. All settings of the list or library are located on this single page. From this page, You can configure List Name, Description, and Navigation options. Similarly versioning, security, etc.
SharePoint Online: PowerShell to Set List Settings
Here is the PowerShell to update most common properties of a SharePoint Online list or library.
#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" #Set Config Parameters $SiteURL="https://crescent.sharepoint.com/" $ListName="Projects" #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 List $List=$Ctx.Web.Lists.GetByTitle($ListName) #Allow management of content types? $List.ContentTypesEnabled=$True #Make "New Folder" command available? $List.EnableFolderCreation=$True #Enable Attachments: Applicable Only for Lists! $List.EnableAttachments=$True #Require content approval for submitted items? $List.EnableModeration=$True #Require documents to be checked out before they can be edited: Applicable Only for Libraries! $List.ForceCheckout=$True #Display this list using the new or classic experience? $List.ListExperienceOptions = "NewExperience" #ClassicExperience or Auto #Draft Item Security $List.DraftVersionVisibility = [Microsoft.SharePoint.Client.DraftVisibilityType]::Approver #Reader, Approver, Author #Quick Edit - Allow items in this document library to be edited using Quick Edit and the Details Pane? $List.DisableGridEditing=$true #Offline Client Availability $List.ExcludeFromOfflineClient = $True #Apply the settings to list $List.Update() $Ctx.ExecuteQuery() Write-host -f Green "List Settings Updated!"You can use this PowerShell script to update document library properties in SharePoint Online as well.
PnP PowerShell to Change List Settings in SharePoint Online:
To configure list settiings, we can use these PnP PowerShell scripts as well.
#Config Variables $SiteURL = "https://crescenttech.sharepoint.com" $ListName ="Projects" #Connect to PNP Online Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) #Get the List $List = Get-PnPList -Identity $ListName #Set List Properties If($List) { #Enable versioning and set Number of versions to 50 Set-PnPList -Identity $List -EnableVersioning $True -MajorVersions 50 #Enable Content Type Management Set-PnPList -Identity $List -EnableContentTypes $True #Content Approval Set-PnPList -Identity $List -EnableModeration $True #Enable Folders Set-PnPList -Identity $List -EnableFolderCreation $True #Enable Attachments Set-PnPList -Identity $List -EnableAttachments $True #Require Checkout Set-PnPList -Identity $List -ForceCheckout $True #Set List Experience Set-PnPList -Identity $List -ListExperience NewExperience }It is also possible to combine these operations in a single line. E.g.
Set-PnPList -Identity $List -EnableAttachments $True -EnableContentTypes $True -EnableFolderCreation $True
My other posts on configuring List settings in SharePoint Online using PowerShell:
- SharePoint Online: Configure Versioning Lists and Libraries using PowerShell
- SharePoint Online: Remove List from Search by Setting NoCrawl Property using PowerShell
- SharePoint Online: Set List Title, Description, Quick launch navigation Options using PowerShell
Here is my another article to get SharePoint Online List Settings: SharePoint Online: PowerShell to Get List Settings
Is it possible to set the Validation Settings of the list using the same powershell?
ReplyDeleteSure, you can use something like:
Delete$list.ValidationFormula = "=[EndDate] > [StartDate]"
$list.ValidationMessage = "End Date must be > Start Date!"
Is it possible to change, Index Non-Default Views?
ReplyDeleteIndex can be added only at the column level!
DeleteIs it possible to set these list settings for all lists?
ReplyDelete