SharePoint Online: Update Content Type using PowerShell

Requirement: Update content type settings in SharePoint Online using PowerShell.

How to Update Content Type Settings in SharePoint Online?

A content type is a reusable collection of metadata (columns), document templates, and other settings that can be assigned to a SharePoint list or library. If you administer a SharePoint Online site, you may need to update the content type settings from time to time. In this article, we’ll show you how to update your content type settings such as content type name, description, and Group using the web browser interface and through PowerShell.

To edit content type’s general settings such as name, description, and group information, follow these steps:

  1. Navigate to the SharePoint Online site where the content type was created.
  2. Click on the Settings gear >> choose “Site Settings”
  3. On the Site Settings page, click on the “Site Content Types” link under the “Web Designer Galleries” section.
  4. On the Site Content Types page, click the name of the content type to be edited.
  5. Click on the “Name, Description, and Group” link in the Settings section.
  6. On the Content Type Settings page, You can update the Name, Description, and Group information as necessary. 
    sharepoint online update content type powershell
  7. Click OK button to save your changes.

SharePoint Online: Update Content Type using PowerShell

Let’s update content type name, description, and group 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"

#parameters
$SiteURL="https://crescent.sharepoint.com/sites/projects"
$ContentTypeID="0x01002A7A908ACAB0054880702EE263AC762B"
 
#Get 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 content type by ID
    $ContentType = $Ctx.web.ContentTypes.GetById($ContentTypeID)
    $Ctx.Load($ContentType)
    $Ctx.ExecuteQuery()

    #sharepoint online update content type powershell
    If($ContentType -ne $Null)
    {
        #Update Content Type Settigs
        $ContentType.Name = "Crescent Project Proposal V2"
        $ContentType.Description="Project Proposal Content Type with Template V2"
        $ContentType.Group = "Crecent Projects"
        $ContentType.Update($False) 
        $Ctx.ExecuteQuery()

        Write-host -f Green "Content Type Settings Updated Successfully!"
    }
    else
    {
        Write-host "Content Type '$ContentTypeName' doesn't exist!'" -f Yellow
    }
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

In conclusion, updating content types in SharePoint Online can be easily done using PowerShell. By following the steps outlined in this article, you can quickly and easily modify the properties of your content types to meet your specific needs. Whether you need to change the description, add or remove columns, or update the document template, PowerShell provides a flexible and efficient solution.

Here are my related posts:

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “SharePoint Online: Update Content Type using PowerShell

  • This is really interesting, can you explain how you use powershell to update the “Required, Optional, Hidden” values for fields within a ContentType on a Modern SharePoint Page? For example how do you change the “Audience” column used for Target Audiences to Required in PnP.PowerShell?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *