Despite working with SharePoint for a long time now the fact that
there are libraries that can’t be deleted by simply going to the list
settings page is one of those things that I haven’t come across too
often. If there’s no ‘Delete this library’ link what can be done – well,
as is becoming the norm, PowerShell to the rescue!
Scenarios where you may see a library like this would be in a site
with the publishing feature enabled. For the case of libraries like the
Images library, Documents library or even the Site Collection Documents
library it is simply not possible to remove them from the lists settings
page or the manage content and structure tool.
The reason for this is that on creation the library has been set as False for the property AllowDeletion:
It is obviously possible to delete the library completely using PowerShell (simply by calling the Delete() method on the list) however both for demonstrations purposes – and also so that you can be absolutely sure that you’re deleting the correct library! – I like the approach of updating the AllowDeletion property to True and then deleting the library through the browser.
This can be done with the simple PowerShell below:
$web = Get-SPWeb http://sp2010/sites/publishing
$list = $web.Lists["Documents"]
$list.AllowDeletion = $True
$list.Update()
And now it’s possible to delete the library through the browser!
Did you spot the bonus feature? By doing the above we also enable the ability to save the library as a template too. I haven’t given this a go (as I wanted to get rid of my library not create more from it!) but I can’t immediately think of a reason why it shouldn’t work.
Note – as I was preparing this post I noticed a similar post
from an ex-colleague who’d used the same approach to remove a Drop Off
Library created by the content organiser feature in SharePoint 2010. You
beat me to the punch Paul!
[By the way, in case you’re thinking that this may never be used, I
actually had to use it in anger recently when a migration had gone
wrong and migrated/ created an image library on a publishing site that
couldn’t be deleted any other way.]
No hay comentarios:
Publicar un comentario