FIX: The operation could not be completed because item was removed from the gallery

Scenario:
You attempt to add a custom web part to a webpage fails with this message:
The operation could not be completed because item was removed from the gallery

Fix:
1. Remove the web part from the web part gallery:
http://site:port/_catalogs/wp/Forms/AllItems.aspx

2. Disable and the re-enable the feature containing the web part (at the web or the site collection level) to add the web part back to the gallery.


Find all pages using a specific Web Part

Scenario:
You are looking for all pages where a specific Web Part is used

PowerShell Script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WebPartPages")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")

$wpName = "Register css web part";
$siteUrl = "http://site:port"
$libraryName = @("Pages");
$site = Get-SPSite $siteUrl;

foreach($spweb in $site.AllWebs)
{
 $url = $spweb.Url;
 foreach($library in $libraryName) {
  $list = $spweb.Lists[$library]
  foreach($listItem in $list.Items) {
   $WebPageUrl = $listItem.Url
   if ($WebPageUrl) {
    if ($spwebpart.Title -and $listItem.File.CheckOutType -ne "None") {
     Write-Host "Skipping checked out page $url/$WebPageUrl" -ForegroundColor Cyan
    }
    $spWpManager = $spweb.GetLimitedWebPartManager($WebPageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);
    foreach($spWebPart in $spWpManager.Webparts) {
     if($wpName -eq $spWebPart.Title) {
      Write-Host "Found '$wpName' on $url/$WebPageUrl" -ForegroundColor Yellow
     }
    }
   }
  }
 }
 $spweb.Dispose();

 if($spWpManager -ne $null) {  
  $spWpManager.Dispose();
 }  
}

Delete broken web part from page

Scenario: 
You have a broken web part on your page and cannot remove it in edit mode

Solution: 
Open your page in maintenance mode by appeding "?contents=1" to the url.

Example:

http://site:port/web/page.aspx
will become
http://site:port/web/page.aspx?contents=1










Here select your webpart and click the "Delete" button.