Get List Of WPs Details From Web Apps To Site Collections

Create a ps1 extension file and save it in your local path.

Change the highlighted part with your Web app URL.

  1. function enumerateWebParts($Url) {  
  2.     $webApp = Get - SPWebApplication $Url# Get WebApplication URL  
  3.     foreach($web in $webApp | Get - SPSite - Limit All | Get - SPWeb - Limit All)# foreach loop to iterate through all sites and webs of WebApplication {  
  4.         if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))# Check  
  5.         if site is a publishing site {  
  6.             $pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)  
  7.             $pages = $pWeb.PagesList  
  8.             foreach($item in $pages.Items) {  
  9.                 $fileUrl = $webUrl + “/” + $item.File.Url  
  10.                 $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);  
  11.                 $wps = $manager.webparts  
  12.                 foreach($type in $wps)# loop through each type found $wps {  
  13.                     if ($type - like "**")#  
  14.                         if webpart $type - like KWizCom select webpart object {  
  15.                         $wps | select - object @ {  
  16.                             Expression = {  
  17.                                 $pWeb.Url  
  18.                             };  
  19.                             Label = "Web URL"  
  20.                         }, @ {  
  21.                             Expression = {  
  22.                                 $fileUrl  
  23.                             };  
  24.                             Label = "Page URL"  
  25.                         }, DisplayTitle, IsVisible, @ {  
  26.                             Expression = {  
  27.                                 $type  
  28.                             };  
  29.                             Label = "Type"  
  30.                         }  
  31.                     }  
  32.                 }  
  33.             }  
  34.         } else#  
  35.             if web is not a publishing site {  
  36.             $pages = $null  
  37.             $pages = $web.Lists["Site Pages"]  
  38.             if ($pages) {  
  39.                 foreach($item in $pages.Items) {  
  40.                     $fileUrl = $webUrl + "/" + $item.File.Url  
  41.                     $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);  
  42.                     $wps = $manager.webparts  
  43.                     foreach($type in $wps) {  
  44.                         if ($type - like "**") {  
  45.                             $wps | select - object @ {  
  46.                                 Expression = {  
  47.                                     $Web.Url  
  48.                                 };  
  49.                                 Label = "Web URL"  
  50.                             }, @ {  
  51.                                 Expression = {  
  52.                                     $fileUrl  
  53.                                 };  
  54.                                 Label = "Page URL"  
  55.                             }, DisplayTitle, IsVisible, @ {  
  56.                                 Expression = {  
  57.                                     $type  
  58.                                 };  
  59.                                 Label = "Type"  
  60.                             }  
  61.                         }  
  62.                     }  
  63.                 }  
  64.             } else {}  
  65.         }  
  66.         Write - Host "… completed processing"  
  67.         $web  
  68.     }  
  69. }  
  70. $row = enumerateWebParts('http://hvsp01:10641’) #call the enumerateWebParts function pass it the URL for the web application  
  71.         $row | Out - GridView  
Open Management Shell as an administrator.

Run PS script, using the path along with the file name in the management shell.

Here, the required output is given below.

output

You can filter the details in a more granular level whenever required.