This script locates all pages in an entire web application that uses connected web parts. the script runs through all the aspx pages in all document libraries of all sites in every site collection and checks if there are web part connections defined. If this is the case it will list the page and the provider and consumer web part title.

The script can easily be adapted to find specific web parts in an entire web application

Use this script in a SharePoint 2010 Management Shell

 

 

PowerShell
Edit|Remove
[int] $count = 0 
$SiteUrl = "http://teams.contoso.com" 
$site = new-Object Microsoft.SharePoint.SPSite($SiteUrl)            
$webapp = $site.WebApplication 
$webapp.Sites | ForEach-Object { 
   $currentSite = $_ 
   $currentSite.AllWebs | ForEach-Object {               
      $currentWeb = $_              
      $lists = $currentWeb.Lists | Where {$_.BaseType -eq "DocumentLibrary"| ForEach-Object { 
         $currentList = $_ 
         $pages = $currentList.Items | Where-Object {$_.Name -match ".aspx"}                
         $pages | ForEach-Object {                  
           $currentPage = $_                  
           $file = $currentPage.File 
           if ($file -ne $null) 
           {   
             $webPartManager = $file.GetLimitedWebPartManager("Shared")                   
             if (($webPartManager -ne $null-and ($webPartManager.SPWebPartConnections -ne $null))                     
             {                           
                  $webPartManager.SPWebPartConnections | ForEach-Object { 
                        $currentWPConnection = $_ 
                        $ConsumerWebPart = $webPartManager.WebParts | Where {$_.ID -eq $currentWPConnection.ConsumerID} 
                        $ProviderWebPart = $webPartManager.WebParts | Where {$_.ID -eq $currentWPConnection.ProviderID} 
                        $count += 1 
                        Write-Host("[{0}][{1}][{2}][{3}]" -$count,$webPartManager.ServerRelativeUrl,$ConsumerWebPart.Title,$ProviderWebPart.Title)                     
                  } 
             } 
           }              
         } 
      }                                     
      $currentWeb.Dispose()          
   }                  
   $currentSite.Dispose() 
} 
$site.Dispose()