SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an content type I would like to delete, but when I try I get an error message saying that it is still in use. Is there a way that I can find all documents that are still using that content type?

share|improve this question
up vote 17 down vote accepted

Here is the code to do this using Powershell:

$site = Get-SPSite("your-site-url");
foreach ($web in $site.AllWebs) {
   $ctype = $web.ContentTypes["Your Content Type"]
   $usages = [Microsoft.Sharepoint.SPContentTypeUsage]::GetUsages($ctype)
   foreach ($usage in $usages) {
      Write-Host $usage.Url
share|improve this answer
It works in a single farm server. But it doesn't work on another App server. What could be the issue? – Strider Apr 2 '14 at 5:19

I needed to do this same thing today. Get a list of SPContentTypeUsage's that define where the items are being used. If the Check if the URL is to a list (such as a Pages library), then run an SPQuery to get those SPListItem's that match your content type. You'll need to iterate over them in a for loop to delete them.

SPContentType ct = site.RootWeb.ContentTypes["CustomContentType"];

IList<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(ct);

foreach (SPContentTypeUsage usage in usages)

    if (usage.IsUrlToList)
        SPList list = web.GetList(usage.Url);
        SPQuery query = new SPQuery();
        query.Query = string.Concat(
                            "<FieldRef Name='ContentType'/>",
                            string.Format("<Value Type='Text'>{0}</Value>", ct.Name),
        SPListItemCollection listItems = list.GetItems(query);
        for (int i = 0; i < listItems.Count; i++)
share|improve this answer
perfect, saved me 30 minutes of investigating. Thanks. – Brian Scott Nov 21 '12 at 9:08

You can use code to delete the content type or report an error stating where it is being used.

Please refer to this simliar question.

share|improve this answer
So it can only be done through code? – Abe Miessler Jun 14 '11 at 21:18
You could use Powershell. I'll write that as a separate answer so it is more readable. – Laurie Jun 14 '11 at 22:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.