Just answer some questions about your experience with Microsoft training. Valid for US & Canadian citizens only. Check it out: http://www.surveygizmo.com/s3/3279913/tech-training-survey-mb
Now…on to our pesky problem about deleting an item from SharePoint!
So, you have a list item or document in a library that no matter what you do, it just won’t let you delete it or undo a check out. You are sure you have the proper permissions, but alas, the document or item is even more stubborn than me and just won’t go away!
- Perhaps one of the issues below has occurred:
- Someone renamed a document that was already uploaded and it became corrupt.
- Something was checked out by another user who is no longer there and it went bonkers so you can’t check it back in to delete it.
- There was custom code written that has somehow altered the document and it has now become unruly.
Here are the steps I perform when I cannot delete documents & list items in SharePoint that are being a wee bit insubordinate:
- Selecting Delete or Undo Checkout. You have probably tried this already or you wouldn’t be reading this article, but here we go. While you are logged in as the Farm Admin or Site Collection Admin, attempt to delete the document or list item by clicking the arrow to the right of the document and selecting delete or checking the box to the left of the document and using the ribbon to select delete.
- Content and Structure. This feature will only be available if Publishing is enabled on your site. By selecting Site Actions –> Manage Content and Structure, follow the same steps above by clicking the delete option in the drop down or via the ribbon under Actions–> delete with the box checked next to the document (if you do not see this option in the drop down you do not have a high enough permission level).
3. Open in Windows Explorer. Thanks to Howard Pearse for this idea. In this example, the context is in Russian, but the button is always in the same place in the ribbon bar (at least in SP2010). This option basically opens the lists/libraries in more of a folder like view. I don’t believe this option is there for a list however, only libraries.
4. PowerShell. As an Administrator, go onto the server and open PowerShell.
- Example – Deleting a document with PowerShell: http://spcodes.blogspot.com/2013/01/powershell-script-to-delete-document-by_4.html
- Example – Deleting a list item with PowerShell: http://social.msdn.microsoft.com/Forums/sharepoint/en-US/de844268-6bb5-4510-9c83-bbca24cf278f/delete-list-item-using-powershell
- *BONUS TIP: (lol – I didn’t know what else to call it…) If you just want to try and discard a page checkout from someone else via PowerShell, check out this script Discarding Check Out Using PowerShell by Roger Cormier on Technet. I had to use $myFile = $myList.Files | out-gridview to get a list of the page titles and alter the script a bit because I think it wants the “Title”, not the file name, but you can play around with it if you like to see if it will work for you.
5. Use SharePoint Designer. Thanks to Divyesh Chauhan for this idea. It is important to perform the steps below as initially when I tried this, I had SPD installed locally on my machine and it deleting the document did not work. Install SharePoint Designer on the server (if you want to take a backup of the server first I understand). Run SPD as an Administrator (right click – Run as Administrator) and make sure you are using either the Farm Admin ID, the System Account or one of the Service Account IDs (you may need to try all of these IDs as I had mixed results myself). You can now uninstall SPD from the server if you would like to.
6. SQL Server Database / SQL Query. Finally, I am mostly certain this is not supported by MSFT, however it has worked for me in the past as an absolute last resort (take a backup of that database before you touch it just in case!). It’s time to go directly into the SQL tables to find the specific item by GUID (The full instructions are included in this blog post from Marc Mathot: http://sharepointfordummies.blogspot.com/2013/05/how-to-delete-corrupt-file-entry-in-sql.html ).
Now that we have the GUID to delete the document, it must be removed from both of these tables:
If you are removing a list item instead of a document, there may be different SQL tables you need to query and delete from than the 2 listed above.
Other Completely Untested, Unsupported, Warranty Invalidating & Farm Disabling Ideas
- If the document is checked out to someone who no longer is there, delete the person’s ID who has it checked out. I am not sure what would happen with this, but feel free to let me know if you are brave enough to do it (evil grin).
Have any other ideas on to remove corrupt or undeletable items and documents from SharePoint? Post your comments below.