How to Get Content Type ID in SharePoint using PowerShell?

Requirement:
Typical usage of Content Types is reusable metadata in SharePoint. At times, You may need to get content type ID by name in order to assign the content type to lists and libraries programmatically. Let’s get the content type ID in SharePoint 2016 using PowerShell.

How to find content type id in SharePoint List?

To get content type ID from the SharePoint interface:

  1. Open your SharePoint List in the browser >> click on “List Settings” from the List tab of the Ribbon.
  2. In the List Settings page, click on your target content type under “Content types” – Assuming content types are enabled already.
  3. Now, You’ll see the ID of the content type in the URL. The last part is the Content Type Id. E.g., https://intranet.crescent.com/_layouts/15/ManageContentType.aspx?List=%7BEE1EA017%2DD347%2D49E6%2D9FE2%2D2CA7D1CB7B57%7D&ctype=0x01160074E6A09BFE52244F8ECB851FF74077FCsharepoint 2013 powershell get content type id

The same procedure applies to site content types as well. Go to Site settings >> Site Content Types >> Pick your content type >> The URL will have the “Ctype” parameter with the content type ID of the respective content type.

SharePoint 2016 PowerShell to get content type id:

Here is the SharePoint PowerShell to find the content type by id, from the list.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Config Parameters
$WebURL="https://intranet.crescent.com"
$ListName="Projects"
$ContentTypeName="Contact Project"

#Get the Web, List and Content Type objects
$Web = Get-SPWeb $WebURL
$List = $Web.Lists.TryGetList($ListName)
#Get the content Type from its name
$ContentType = $List.ContentTypes | Where {$_.Name -Match $ContentTypeName}

#sharepoint get content type id by name
Write-Host $ContentType.ID 

Similarly, to get the site content type ID in SharePoint with PowerShell, use:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Config Parameters
$WebURL="https://intranet.crescent.com"
$ContentTypeName="Crescent Configuration Entry"

#Get the Web, List and Content Type objects
$Web = Get-SPWeb $WebURL
#Get the content Type from its name
$ContentType = $Web.ContentTypes | Where {$_.Name -Match $ContentTypeName}

#sharepoint get content type id by name
Write-Host $ContentType.ID
How to get a content Type by ID?
$CT = $Web.ContentTypes | Where {$_.ID -eq “0x01005B3FBCA1E5314D57B4198D54F9F9B9CD”}

Similarly, to retrieve the content type ID in SharePoint Online, use: How to get content type ID in SharePoint Online using PowerShell?

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

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