Skip to main content

Powershell Script to empty admin recyle bin in SharePoint

a script wherein if we give an user name for ex Deleted By "Bai,Mala(Mala)",it should delete the all the files which were deleted by user.


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$siteURL = "your site url"
$site= New-Object microsoft.sharepoint.spsite($siteURL)
$query = new-object Microsoft.SharePoint.SPRecycleBinQuery;
$query.ItemState = “FirstStageRecycleBin”;
$itemcoll = $site.GetRecycleBinItems($query);

#Delete items those are deleted by Mala

$files= $itemcoll | where {$_.DeletedByName -match "your name"}

#Delete output
foreach ($file in $files) {
$site.RecycleBin.Delete($file.ID)

}

Comments

Popular posts from this blog

Control when a document is displayed: Managing Item Scheduling

How to enable Scheduling Start Date and Scheduling End Date for pages /Documents library for Subsites. 1. After creating new Document library  / pages  go to List Settings. 2. In section General Settings select the link Versioning Settings, and enable" 1) Content approval to Yes . 2) Dcoument version history to created major and minor(draft) version . 3. In Section General Settings select the link " Manage Item Schueduling and select the option Enable scheduling of items in this list . 4. You will see Scheduling Start Date and Scheduling End Date in allitems pages.

Add a site template to Central Administration so it's available when you create a new site collection

When you create a new site collection, Central Administration creates a top level site and offers you the standard set of templates for that top level site. If you want to add a custom template to the list of templates offered by Central Administration, simply: From the command prompt, use STSADM -O ADDTEMPLATE: stsadm.exe -o addtemplate -filename filename -title "friendly name" -description "description" Type stsadm -help addtemplate for details. Then restart IIS by typing iisreset.