SharePoint Online: Set Default Content Type using PowerShell

Requirement: Set Default Content Type in SharePoint Online List using PowerShell

How to change the default content type in SharePoint Online?

A SharePoint list can have multiple content types. There are situations where you may want to set the default content type which appears in the new button. You can specify which of the available ones is the default for the list or library by setting the order of the listed content types. To set a default content type, do the following:

  1. Navigate to the SharePoint Online list or library where content types need to be managed.
  2. Go to List or Library Settings >> On the Settings page, Click on “Change New Button Order and Default Content Type” link under Content Types section.
  3. On the Change New Button Order page, You can move the relevant content type to the first position. Content type which appears at first position will become the default content type for the list.
  4. Click the OK button to save the changes.

You can update to the content type ordering and visibility details for the list or library.

set default content type sharepoint online powershell

Set Default Content Type in SharePoint Online list using PowerShell

How to make a content type default in SharePoint Online? Well, Here is the PowerShell script to reorder content types in a SharePoint Online List. The Item in the first index becomes the default content type automatically. This script doesn’t remove or re-add the content type from the list, it simply changes the order of the content type sequence.

#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 Variables
$SiteURL= ""
$ListName = "Business Contacts"
$ContentTypeName = "Contacts"

#Setup Credentials to connect
$Cred = Get-Credential
Try {
    #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 Content Types
    $List = $Ctx.Web.Lists.GetByTitle($ListName)

    #Create a List for content types
    $ContentTypeOrder = New-Object System.Collections.Generic.List[Microsoft.SharePoint.Client.ContentTypeId]

    #Add the Default content type to the First Index  
    ForEach($ContentType in $List.ContentTypes)
        If($ContentType.Name -eq $ContentTypeName)
    #Add Rest of the content types to the Content type Order List
    ForEach($ContentType in $List.ContentTypes)
        If($ContentType.Name -ne $ContentTypeName -and $ContentType.Name -ne "Folder")
    #Set Content type Order
    $List.RootFolder.UniqueContentTypeOrder = $ContentTypeOrder
    Write-host -f Green "Default Content Type has been updated successfully!"
Catch {
    write-host -f Red "Error: " $_.Exception.Message

Set Default Content Type in SharePoint Online List using PnP PowerShell

To change the default content type in SharePoint Online list or library, use this PowerShell:

#Set Variables
$SiteURL = ""
$ListName = "Projects"
$ContentTypeName = "Crescent Projects V2"

#Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Set Default Content Type of the List
Set-PnPDefaultContentTypeToList -List $ListName -ContentType $ContentTypeName

Please note, the content type must be added to the list already!

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

One thought on “SharePoint Online: Set Default Content Type using PowerShell

  • October 16, 2020 at 10:08 PM

    How to add a retention like a 1 year, 2 year etc to a content type for a site collection I have created. I need to be able to do this using powershell PNP. Is there a way to do this?


Leave a Reply