Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to find out on which (sub)sites a certain webpart is used. In a data sharing environment with many subsites and pages, I want to check if and where certain (third party) webparts are used. Is there a way to get a list of the locations where it is on the page?

Or more general: How do I find out where a feature is used? (For instance a site-template, when is it safe to uninstall it)

share|improve this question
    
Thank you for sharing informative command. Quick question - How can I exclude the OOB? I wanted to find what custom webpart, eventreceiver, etc are in use. Thanks, Khushi –  user19623 Sep 19 '13 at 15:45
add comment

3 Answers

up vote 13 down vote accepted

The best way to do get a quick view of what is being used where in a given content database is with the stsadm command enumallwebs using the addtional parameters supplied with the October 2009 Cumulative Update:

stsadm -o enumallwebs -includefeatures -includewebparts -includeeventreceivers -includesetupfiles -includecustomlistview

There's also a useful MVP article which is worth reading.

share|improve this answer
1  
Wow, interesting, didn't know this, +1. I wonder if they have similar cmdlet for SharePoint? –  Andrey Markeev May 17 '11 at 10:02
    
Maybe my google-fu is down, but I couldn't find a technet reference to the 'new' options coming from the October 2009 CU. –  Dribbel May 17 '11 at 10:38
    
And Thanks! Too bad our farm is still on SP2 (no extra CUs) –  Dribbel May 17 '11 at 10:38
    
Don't think TechNet has caught up with this. For PowerShell I think you can do it by scripting the existing cmdlets and maybe a bit of object model, but may as well use stsadm for now. –  SPDoctor May 17 '11 at 10:49
    
You could take a backup and restore to a temporary SharePoint installation and install the CU there (DBAs permitting). –  SPDoctor May 17 '11 at 10:54
add comment

You could do this through PowerShell. I used this script as a basis and created the following script to list all webparts of all pages in all webs in a site collection. Take a look:

# Basis: http://www.glynblogs.com/2011/07/listing-all-web-parts-in-a-site-collection-with-powershell.html
# Modified by http://sharepoint.stackexchange.com/users/2509/tarjeieo
function EnumAllWebPartsOfSiteCollection($Url) {
    $site = new-object Microsoft.SharePoint.SPSite $Url 
    $allFiles = @()
    foreach($web in $site.AllWebs) {
        Write-Host "Processing Web:" $web.Url -NoNewLine
        if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) {
            $pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
            $pages = $pWeb.PagesList

            foreach ($item in $pages.Items) {
                $allFiles += $item.File
            }
        }
        $pages = $null
        $pages = $web.Lists["Site Pages"]
        if ($pages) {
            foreach ($item in $pages.Items) {
                $allFiles += $item.File
            }
        }
        foreach ($file in $web.Files) {
            $allFiles += $file
        }
        $web.Dispose()
        Write-Host " - completed"
    }
    foreach ($file in $allFiles) {
        $fileUrl = $Url + $file.ServerRelativeUrl
        $manager = $file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
        $wps = $manager.webparts
        $manager.Dispose()
        $wps | select-object @{Expression={$file.Web.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"}, DisplayTitle, IsVisible, @{Expression={$_.GetType().ToString()};Label="Type"}
    }
    $site.Dispose()
}

$row = EnumAllWebPartsOfSiteCollection('http://test:1337')
$row | Out-GridView
share|improve this answer
    
This worked well for me since it includes all the web parts on non publishing / team sites as well which is what I needed –  pigeon May 23 '13 at 3:57
add comment

For 2010, the Get-SPFeature cmdlet "Returns the SharePoint Features based on a given scope." But you still can use that enumallwebs command because PowerShell won't do all it does yet.

share|improve this answer
add comment

Your Answer

 
discard

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.