SharePoint 2010 + PowerShell: Delete Site Content Type

Note: As of 2025, SharePoint Server 2010 is long out of support. The following script is historical and applies to SharePoint 2010 on‑prem environments.

So first, you have to delete all of the content type's children or you'll receive the error "Error: content type in use." Once the dependencies are gone, you can delete the custom site content type itself.

 1$sitename    = $args[0]
 2$contentType = $args[1]
 3
 4$web = Get-SPWeb $sitename
 5$ct  = $web.ContentTypes[$contentType]
 6
 7if ($ct) {
 8    $ctusage = [Microsoft.SharePoint.SPContentTypeUsage]::GetUsages($ct)
 9    foreach ($ctuse in $ctusage) {
10        $list = $web.GetList($ctuse.Url)
11        $contentTypeCollection = $list.ContentTypes
12        $contentTypeCollection.Delete($contentTypeCollection[$ContentType].Id)
13        Write-Host "Deleted $contentType content type from $ctuse.Url"
14    }
15    $ct.Delete()
16    Write-Host "Deleted $contentType from site."
17} else {
18    Write-Host "Nothing to delete."
19}
20
21$web.Dispose()

Voila.