Monthly Archives: September 2012

Display Lists & Libraries That Use a Specific Content Type in SharePoint 2010

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”)      
{ $lst.DefaultViewUrl
}   

}  
$web.Dispose()
}

 

List All Web Parts in a SharePoint 2010 Site Collection Using Windows PowerShell

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.

 function enumerateWebParts($Url) {
    $site = new-object Microsoft.SharePoint.SPSite $Url    foreach($web in $site.AllWebs) {
        if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) {
            $pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
            $pages = $pWeb.PagesList
            foreach ($item in $pages.Items) {
                $fileUrl = $webUrl + “/” + $item.File.Url
                $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
                $wps = $manager.webparts
                $wps | select-object @{Expression={$pWeb.Url};Label=”Web URL”},@{Expression={$fileUrl};Label=”Page URL”}, DisplayTitle, IsVisible, @{Expression={$_.GetType().ToString()};Label=”Type”}
            }
        }
        else {
            $pages = $null
            $pages = $web.Lists[“Site Pages”]            if ($pages) {                foreach ($item in $pages.Items) {
                    $fileUrl = $webUrl + “/” + $item.File.Url
                    $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
                    $wps = $manager.webparts
                    $wps | select-object @{Expression={$pWeb.Url};Label=”Web URL”},@{Expression={$fileUrl};Label=”Page URL”}, DisplayTitle, IsVisible, @{Expression={$_.GetType().ToString()};Label=”Type”}
                }
            }
            else {
            }
        }        Write-Host “… completed processing” $web
    }
}$row = enumerateWebParts(‘http://sharepoint2010/sites/spquester’)
$row | Out-GridView

If the Integrated Script Editor (ISE) is not installed, execute the following script then go back to the script above and execute it.

Import-Module ServerManagerAdd-WindowsFeature PowerShell-ISE

Exploring the Datasheet View Task Pane in SharePoint 2010 Lists

Video Length: 2:29

Video description: This video explores the task pane in the Datasheet view of a SharePoint 2010 list/library.

Read more »