SharePoint onPrem: Create ContentType with the specific ID
At my previous job I was happy to work with SharePoint on-premises. More than 10 years with SP 2007, 2010 and finally 2019. Almost 3 years ago I thought I won't cooperate with it. In May 2026 the support of SharePoint server ends. But as it turned out many companies still use SP on-prem and don't want to migrate.
It means that the posts with the snippets can still be useful as for me, so and for other users.
This post is about how to create ContentType with the specific ID. Of course, it can't be totally specific - it must use the part of the name of the parent ContentType.
Prerequisites:
- SharePoint PowerShell console
- Account with access to PowerShell and SiteAdmin permissions (better Site Collection admin)
- Access to the SharePoint Server
PowerShell Code
$siteUrl = "http://mydev01:2555/"
$web = Get-SPWeb $siteUrl
$ctName = "ABRequest"
$ctGroup = "ABRequests"
$ctId = "0x01000BB567D4159F48249AAEC0D68DACD356"
# Parent CT
$parentCT = $web.AvailableContentTypes["Item"]
$parentId = $parentCT.Id
# Check if CT already exists
if ($web.AvailableContentTypes | Where-Object { $_.Id.ToString() -eq $ctId })
{
Write-Host "Content Type already exists"
return
}
# IMPORTANT: create ID first
$customCtId = New-Object Microsoft.SharePoint.SPContentTypeId($ctId)
# Create content type WITH ID
$ct = New-Object Microsoft.SharePoint.SPContentType(
$customCtId,
$web.ContentTypes,
$ctName
)
$ct.Group = $ctGroup
$ct.Description = "ABRequest content type"
$web.ContentTypes.Add($ct)
$web.Update()
Write-Host "ABRequest Content Type created successfully"
