SharePoint Delete Items and files directly or using recycle bin by using Powershell

When you use a Powershell Script to work on SharePoint List items or Files you can do a lot of things. One of those things for example is deleting items which are not needed anymore. Therefore you can use a Powershell function like

$listitem.Delete()

This means that the list item or file will be deleted permanently. It will not be in the SharePoint recycle bin and not in the secondary recycle bin. It is lost forever if you not have it in one of your backups.

So what if, if you would like to delete it, but put it into the recycle bin? Therefore you should not use the delete() function. In this case you should use the following

$listitem.Recycle()

This will put the item into the secondary recycle bin SharePoint offers. You can reach this one if you click on site settings and then below Site Collection Administration the link to the recycle bin

SC_Recyclebin

SC_Recyclebin2

Normally this recycle bin will be emptied after a certain period which can be configured in the central administration.

One of my questions is now – Can we put those files also into the first recycle bin for the enduser? If you know it, please let me know.

In this post there is a little explaination based on SharePoint 2007.

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.