SharePoint 2010 + PowerShell: View Dependencies of Content Types (aka Content Type Usage)

Earlier today, I created some test Content Types while playing around with the fancy new Content Organizer. I ran into a few errors, though, and subsequently wanted to delete the dummy content types to start over. I was unable to, however, because the content types were still in use. By what? I didn't know.

Too bad SharePoint doesn't have a feature similar to SQL Server Management Studio's "View Dependencies." Till it does.. here is a PowerShell script that does the trick.

$sitename= "https://sharepoint" $contentType = "My Custom Content Type"

$web = Get-SPWeb $sitename $ct = $web.AvailableContentTypes[$contentType] $ctusage = [Microsoft.SharePoint.SPContentTypeUsage]::GetUsages($ct) foreach ($ctuse in $ctusage) { $ctuse.Url }

$web.Dispose()   Looking for content type usage within subsites? A more thorough script can be found at StackExchange.