the following powershell script will allow you to identify site collections where a given webpart is used. Very usefull during migrations when you have identified the web parts that cannot be upgraded and need to know where they are used. The script allows you to specify a scope of webapp or site collection to go through and look into the web part gallery to check if the web part is present.
Prerequisites for this script is having Powershell 2.0 deployed on the SharePoint 2007 server.
 
PowerShell
Edit|Remove
Param($Scope,$Url,$Webpart,$LogFile) 
 
#Define Variables 
[bool]$transcript_enabled = $false 
[string]$usage = "Usage: Find-WebPart.ps1 -Scope WebApp|Site -Site <site url> -Webpart <webpart name> -LogFile <file name>"  
[int]$GLOBAL:TotalSiteswithWebPartFound = 0 
 
function Find-WebPart-Collection([string]$SiteCollectionURL,[string]$WebPartName) 
{ 
    $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) 
    $wpCatalog = $site.GetCatalog([Microsoft.SharePoint.SPListTemplateType]::WebPartCatalog)  
    Write-Host "$SiteCollectionURL : " -nonewline 
         
    if ($site -eq $null) 
    { 
        Write-Host "Cannot get the site collection corresponding to $SiteCollectionURL" -foregroundcolor red -backgroundcolor yellow  
        Write-Host "Check the Url and try again" -foregroundcolor red -backgroundcolor yellow  
        if ($transcript_enabled -eq $true) { Stop-Transcript } 
        exit    
    } 
    $found = $false 
    foreach($item in $wpCatalog.Items)  
    {  
        $itemName = $item.Name 
    if ( $itemName.ToLower() -eq  $WebPartName.ToLower() ) 
    { 
        Write-Host "Web Part $WebPartName found" -foregroundcolor green 
        $GLOBAL:TotalSiteswithWebPartFound += 1 
        $found = $true 
        } 
    } 
    if ( $found -eq $false ) 
    { 
        Write-Host "Web Part $WebPartName  not found" -foregroundcolor red  
    }  
    $site.Dispose() 
 
} 
 
function Find-WebPart([string]$WebAppURL,[string]$WebPartName) 
{ 
     
    if ($Scope.ToLower() -eq "webapp") 
    { 
       $Thesite = new-object Microsoft.SharePoint.SPSite($WebAppURL) 
       $oApp = $Thesite.WebApplication 
 
       foreach ($Sites in $oApp.Sites) 
       { 
          $mySubweb = $Sites.RootWeb 
          [string]$TempRelativeURL = $mySubweb.Url 
          Find-WebPart-Collection $TempRelativeURL $WebPartName 
        } 
       $Thesite.Dispose() 
    } 
    if ($Scope.ToLower() -eq "site") 
    { 
        Find-WebPart-Collection $WebAppURL $WebPartName 
         
    } 
     
} 
 
function StartProcess() 
{ 
    # Create the stopwatch 
    [System.Diagnostics.Stopwatch] $sw; 
    $sw = New-Object System.Diagnostics.StopWatch 
    $sw.Start() 
 
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 
    Find-WebPart $Url $WebPart 
 
    $sw.Stop() 
    # Write the compact output to the screen 
    Write-Host "------------------------------------------------------" 
    write-host $GLOBAL:TotalSiteswithWebPartFound " Sites with Web Part. Time elapsed = "$sw.Elapsed.ToString() 
     
} 
 
# START SCRIPT 
 
if ($Scope -eq $null) 
{ 
  Write-Host "No Scope parameter has been passed" -foregroundcolor red -backgroundcolor yellow | out-default 
  Write-Host $usage | out-default 
  exit 
} 
if ($Scope.ToLower() -ne "webapp" -and $Scope.ToLower() -ne "site") 
{ 
  Write-Host "Invalid Scope parameter has been passed" -foregroundcolor red -backgroundcolor yellow | out-default 
  Write-Host $usage | out-default 
  exit 
} 
if ($Url -eq $null) 
{ 
  Write-Host "No Url parameter has been passed" -foregroundcolor red -backgroundcolor yellow | out-default 
  Write-Host $usage | out-default 
  exit 
} 
 
if ($LogFile -ne $null) 
{ 
    $transcript_enabled = $true 
} 
 
 
cls 
Write-Host "Scope   = "$Scope 
Write-Host "Url     = "$Url 
Write-Host "Webpart     = "$WebPart 
Write-Host "LogFile = "$LogFile 
Write-Host "------------------------------------------------------" 
 
if($transcript_enabled -eq $true) 
{ 
    Start-Transcript -Path $LogFile -Append 
} 
 
StartProcess 
 
if($transcript_enabled -eq $true) 
{ 
    Stop-Transcript 
}