SharePoint Online: Enable Content Types using PowerShell

As the name suggests, Content type defines type of the content such as item or document. In a real world scenario, A content type could refer to a invoice template or project plan document, etc. Content types provide a effective method of grouping relevant columns (metadata), document template, workflows and policies together and helps to standardize a template for reuse. Typically content types are created at the top level site as they are hierarchical in nature. In other words a content type created at root site gets inherited to all its subsites automatically. This saves lot of time as you need to create that content type only once and reuse it wherever required.

How to Enable Content Types in SharePoint Online?

Before adding content types to a list or library, We must enable content type management in list or library settings. To enable content type in SharePoint Online list,

  • Go to List >> List Settings >> Advanced Settings
  • Set “Yes” for “Allow management of content types?” and hit OK button to save your changes.
    enable content types in sharepoint online

If you go back to list settings, you’ll find a section “Content Types” with the particular list or library’s default content type listed (E.g. Item for custom list!). You an add any existing content types to the list now!

PowerShell to Enable Content Types in SharePoint Online List using PowerShell:

#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"

#function to turn ON Content Type in SharePoint Online list or library
Function Enable-ContentTypes()
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $ListName

    Try {
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        #Get the List object
        $List = $Ctx.Web.Lists.GetByTitle($ListName)

        #Check if content types are already enabled
        If($List.ContentTypesEnabled -eq $True)
            Write-host "Content Types Already Enabled in the given List!" -ForegroundColor Yellow
            #enable content types in the list

            Write-host "Content Types Enabled for given List Successfully!" -ForegroundColor Green  
    Catch {
        write-host -f Red "Error enabling Content Type!" $_.Exception.Message

#Set parameter values

#Call the function
Enable-ContentTypes -SiteURL $SiteURL -ListName $ListName

PnP PowerShell to Enable Content Type on a SharePoint Online List:

#Config Variables
$SiteURL = ""
$ListName = "Projects"

#Connect to Site collection from PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Enable Content Type
Set-PnPList -Identity $ListName -EnableContentTypes $True

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!

Leave a Reply