netnerds.net

6Sep/110

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= "http://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.

Posted by: Chrissy   Filed under: PowerShell, SharePoint Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.