none
Content Type Usage for all web collection

    Question

  • Hello

    I want to generrate a report for content type usage only for document libraries, this report will have following columns

    Content Type Name

    Usage Count (Total no of count which tell how many time content type used)

    Site Count (which tell in how many site content type is used)

    I created following code, which is listing the content type name and its usage count. I want to run this script for document libraries and for all site collection. Please let me know how can I do this? I dont want to use PowerShell script.

    SPWeb web = ospSite.OpenWeb();
                    
                    SPWebCollection collWebsites = ospSite.AllWebs;
    		     
                        SPContentTypeCollection col = web.AvailableContentTypes;
                        foreach (SPContentType contenttype in col)
                        {
                            usageCount = Microsoft.SharePoint.SPContentTypeUsage.GetUsages(web.ContentTypes[contenttype.Name]).Count;
                            Response.Write(contenttype.Name.ToString() + " - " + usageCount.ToString() +  "<br>");
                        }

    Regards

    Avi

    Wednesday, October 16, 2013 11:41 AM

All replies