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

Differences between Windows SharePoint Services (WSS) and Microsoft Office SharePoint Server 2007 (MOSS)

WSS is included as a part of the Windows Server 2003 whereas MOSS is a separate product.WSS doesn’t have its own licensing model, it is controlled through Windows Server licenses whereas MOSS has it own licensing model that includes both Server-Side as well as client accesses licenses. MOSS includes all the features of WSS and adds its own set of components as services. Additional features that are part of MOSS includes Collaboration Social networking web parts – Colleague Web Part, Colleague Tracking Web Part, In Common Web Part etc. Enterprise search Enterprise content sources Files shares, Web sites, SharePoint sites, Exchange Public Folders, and Lotus Notes databases, more relevant results, people search, business data search.