Cleaning up a drop off library mess

You installed SharePoint, then your power users enabled the content organizer feature all over your farm. This isn’t necessarily a bad thing, but if it’s not being used, turn it off! Less load on the farm, the better off you will be.

You will find plenty of examples on the web about cleaning up this mess, but I took a slightly different approach. Before disabling the feature and deleting the library, I first checked to make sure the library was empty and no content org rules had been created.

Start-SPAssignment -Global

$web = Get-SPWeb "http://webapp.sharepointed.com"
$feature = Get-SPFeature "7ad5272a-2694-4349-953e-ea5ef290e97c" 

   if ($web.Features[$feature.ID]) 
   {
            $corList = $web.lists["Content Organizer Rules"]
            $dolList = $web.lists["Drop Off Library"]
            
            #check for Cont Org Rules and items in Drop Off Library
            if(($corList.ItemCount -eq 0) -and ($dolList.ItemCount -eq 0))
            {
                  #disable the feature
                  Disable-SPFeature -Identity "7ad5272a-2694-4349-953e-ea5ef290e97c" -Url $_.URL -Confirm:$false
                  
                  #remove the Drop Off Library
                  $dolList.AllowDeletion = $true
                  $dolList.Update()
                  $dolList.Delete()
            }
   } 

Stop-SPAssignment -Global

PowerShell SharePoint Delete Web Part

Migrated a company from SharePoint 2007 to SharePoint 2010 and hit another small bump in the process.

The core issue was related to the AllItems.aspx page in a given library had a Content Editor web part on the page. Why?  No idea, but when users tried to access the library, the Documents and Library tab were missing from the Ribbon.

This wouldn’t be an issue if I was dealing one library.

In my case, I had a Site Collection with a dozen sites, then under each of those sites were 100+ sites.  So, I only needed to update ~1,000 sites.

Options:
A. Hire someone to edit ALL of those sites / pages.
B. Our great friend PowerShell!

What I’m doing in the script:
Starting at the Site Collection.
Loop on each site.
Looping on each List in the site.
When site = Random Documents dig in a little deeper.
Get the web parts on the AllItems.aspx page.
Loop on the web parts.
If web part title = “Content Editor Web Part”
Delete it.

 $site = Get-SPSite "http://sharepointed.com/SiteCollection"

foreach ($web in $site.AllWebs)
{
foreach($List in $web.Lists)
{
If($list.Title -eq "Random Documents")
{
$webpartmanager = $web.GetLimitedWebPartManager(($web.Url + "/Random%20Documents/Forms/AllItems.aspx"), [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

for($i=0; $i -lt $webpartmanager.WebParts.Count; $i++)
{
if($webpartmanager.WebParts[$i].Title -eq "Content Editor Web Part")
{
$webpartmanager.DeleteWebPart($webpartmanager.Webparts[$webpartmanager.WebParts[$i].ID])
}
}
}
}
$web.Update()
$web.Dispose()
}
$site.Dispose()

Powershell delete items in a list or library

There might be a better way to accomplish this… but for now this works.  Just needed a way to delete all the items in a list.

[System.reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
$spsite = New-Object -TypeName “Microsoft.SharePoint.SPSite” -ArgumentList http://win-vm3$spweb = $spsite.OpenWeb()

$splist = $spweb.Lists[“NameofList”]

$items=$splist.get_items() | where { $_.Title -like ‘*’ }
$items | % { $_.Delete() }

$spweb.Dispose()

$spsite.Dispose()