Applies To: SharePoint 2010
The other day I came across a problem with some missing features on a few of our sites. Some quick searching told me I needed to enable all my sites to use the SharePoint Server Enterprise Features. This is a good thing to do, especially if you’ve just upgraded from 2007 to 2010 or you were using Foundation or Standard Server.
So, I went to Central Administration and clicked on Upgrade and Migration and chose Enable Features on Existing Sites. I was presented with this screen:
So, I checked the box and pressed OK. It took a few hours, but then everything was good to go! Almost…
Turns out I had people asking me what this new Drop Off Library link was on their sites. A quick check showed that EVERY SITE in EVERY SITE COLLECTION in EVERY WEB APPLICATION now had the Content Organizer feature enabled and a Drop Off Library added.
So, I go to Manage Site Features I deactivate the Content Organizer and go to delete the Drop Off Library. No delete option in Library settings. Turns out you need to use something like SharePoint Manager or Powershell to allow the library to be deleted before that link will show up. Regardless, we have hundreds of sites and my sites – All of which now have an unremovable library and unnecessary feature activated.
So, time for some Powershell! I wrote a script (below) that will cycle through all the sites in all the site collections for a given Web Application and disable the DocumentRouting feature (Content Organizer) and delete the Drop Off Library. I was inspired by this forum thread and this blog post.
Additionally, I was also faced with the complication that I had actually activated this feature previously for a few sites and wanted to make sure they weren’t stripped along with everybody else. So I added an ExclusionURLs parameter. I’ll explain more about that and how the rest of the script works in a minute.
The Script
Param( [parameter(position=0)] [String] $WebApplicationURL, [parameter(position=1)] [Boolean] $AnalysisOnly = $true, [parameter(position=2)] [String[]] $ExclusionURLs ) #Display Exclusion URL information if($ExclusionURLs -and $ExclusionURLs.Count -gt 0) { Write-Host "Excluded URLs:" -foregroundcolor green $ExclusionURLs | ForEach-Object { Write-Host " $_" -foregroundcolor green } } else { Write-Host "No URL Exclusions" -foreground cyan } #Display Feature Information $feature = Get-SPFeature “DocumentRouting” Write-Host “Feature ID for Content Organizer is called $($feature.DisplayName)" -foregroundcolor cyan if($AnalysisOnly) { Write-Host "ANALYSIS ONLY" -foregroundcolor red } #Go Through Every Site Get-SPWebApplication $WebApplicationURL | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | ForEach-Object { #Check for Exclusion if(!($ExclusionURLs -contains $_.URL)) { Write-Host "$_ | $($_.URL)" -foregroundcolor DarkCyan #Disable Feature if found if ($_.Features[$feature.ID]) { Write-Host “ Feature $($feature.DisplayName) Found" -foreground green if(!$AnalysisOnly){ Disable-SPFeature $feature -Url $_.Url -Force -Confirm:$false Write-Host “ Feature $($feature.DisplayName) Disabled” -foreground magenta } } else { Write-Host " Feature $($feature.DisplayName) NOT Found" -foreground yellow } #Delete Drop Off Library if found $list = $_.Lists["DROP OFF LIBRARY"] if ($list) { Write-Host “ List $list Found” -foregroundcolor green if(!$AnalysisOnly){ $list.AllowDeletion = $true; $list.Update() $list.Delete() Write-Host “ List $list Deleted” -foreground magenta } } else { Write-Host “ Drop Off Library NOT found” -foregroundcolor yellow } } } Write-Host " " Write-Host "All Done!" -foregroundcolor yellow
You can copy the above script, save it in a text file with a ps1 extension and run it from the console. Assuming you’ve named the file RemoveDropOffLibraries.ps1 you can run it in a couple of different ways:
Analysis Only:
Since I’m the cautious type, I want to know which sites are going to be affected before I actually pull the trigger. So running it with just the Web Application URL will provide you with a list of all sites. Additionally, you’ll be told if a given site has the DocumentRouting feature enabled and if a Drop Off Library was found.
Perform Actions:
If you’re comfortable with the results above, just pass the Web Application URL and $false for the AnalysisOnly parameter. This will do the same list of sites and indicate if the DocumentRouting feature is enabled and if a Drop Off Library was found. Each time the feature is found activated, it gets disabled and you’ll see a message. Additionally, each time a Drop Off Library is found, it gets deleted and you’ll see a message.
Analysis Only with Exclusions:
Exclusions allow you to pass site URLs in a comma separated list. Doing the above command ensures your exclusions are working. Just specify the Web Application URL, $true for AnalysisOnly and then 1 or more exclusion URLs separated only by a comma.
Perform Actions with Exclusions:
This uses the same rules for exclusions as above, but instead of just analyzing, it actually does the work.
Quick Tip:
If you have a lot of sites and want to be able to see the output easily, use the start-transcript and stop-transcript cmdlets like so:
start-transcript -path SomeFile.rtf ...Commands and Output... stop-transcript
Just replace line 2 with one of the command examples from above.
Surely no one else will ever end up in this situation, but just in case – there ya go!
Excelllent Script! I wanted to test it on a single site collection and added an
if($_.URL -eq “http://….)
{
}
after the
#Go Through Every Site
Get-SPWebApplication $WebApplicationURL | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | ForEach-Object {
Since I like to use the ISE Version of PS I also changed the variables $WebApplicationURL and $AnalysisOnly accordingly.
Thanks so much for this! Ran into the same annoyance after getting InfoPath Form Services up and running.
Thanks! We had the same issue where a farm admin (who’s no longer an admin) went in and activated the Enable Enterprise Features. Not only did we get the Drop Off Library as you did, we also got the Document ID Service. Did you get Document IDs, too? If so, What did you do about cleaning them out?
Thank You, Thank You, Thanks You!!!!
Do you have an easy fix for all of the groups / users it created?
Fantastic script, thanks muchly!
As a followup… I opened a Support ticket with Microsoft about getting rid of the Document IDs and tried to tag along the whole question about activating the Enterprise Features through “Enable Enterprise Features” (MS Support doesn’t like such scope creep, so they wouldn’t address to overarching issue). The short of the matter: removal of many of the features activated by “Enable Enterprise Features” is UNSUPPORTED. In the case of Document IDs, you have to unprotect a field in order to remove it (unsupported). Was quite frustrated that MS doesn’t provide a way to cleanly remove the features on deactivation, but could understand both sides of the issue (think of the havoc that would be caused in the Drop Off Library were removed when users had documents in it that they wanted). When I get the chance, I’ll post all about my findings and how I went about cleaning it up (without Support): http://spsawyer.wordpress.com.
This is awesome! Thank you so much!
[…] Kent hat auf seinem Blog ein nützliches Script gepostet, das in jeder Site das Content Organizer Feature wieder deaktiviert […]