SharePoint content types encapsulate data requirements, enable content standardization, and are independent of file formats which makes them popular to use across SharePoint. Fast forward to a few hundred content types used within a large SharePoint environment and you’ll soon need to pay attention to managing these content types and answering question such as how many custom content types do we have and where are they being used.
A specific scenario this post addresses is the need to report on a specific content type use within a site collection. The video and script below highlight the process you’d need to take to generate such a report.
Video length: 2:24 min
To list a specific content type usage within a site collection copy and paste the following script into the SharePoint 2010 Management Shell.
Note: Two things to change: 1. The site collection address and 2. The content type name
$webs = get-spsite http://sharepoint2010/sites/portal14| get-spwebforeach ($web in $webs)
foreach ($lst in $web.lists)
foreach ($ctype in $lst.ContentTypes)
if ($ctype.Name -eq “Document”)
I won’t make this overly complex, but if your organization is rapidly growing with SharePoint and you, farm admin, or your site collection administrators, or even your site owners are all super excited about SharePoint’s capabilities and you are provisioning sites or pages to justify the ever growing demands of your business, then you probably are adding hundreds of web parts to your sites and pages.
In most cases, these web parts are simply what shipped with the product and what gets placed on the sites once you provision them such as ‘Shared Documents’ or ‘Announcements’. In other cases, they maybe web parts developed in house by your development team to meet a specific demand such as ‘a moving average chard web part’ or even purchased from a third party vendor like Quest Software or Bamboo Solutions.
In any case, as your SharePoint succeeds and grows, and again, as you drop more web parts to your pages, the need to control and understand were these web parts are becomes super important. You will want to know which web parts are open and which ones are closed, which ones are used and which ones are not, which ones are affecting load time on pages and which ones are causing errors.
The video below captures the steps involved in executing a Windows PowerShell script that will loop through pages on publishing and non-publishing sites, finds all web parts, and outputs the result to a grid view.
Video length: 2:27
Use the below script to list all web parts in a site collection. The script loops through all pages, publishing and non-publishing sites, finds all web parts, and displays them on a grid view.
Note: Make sure you change the URL at the bottom of the script to your site collection URL.