SharePoint Online: Search Recycle bin using PowerShell
Requirement: Search SharePoint online recycle bin for all files deleted by a particular user
How to search SharePoint Online Recycle Bin?
To find all items deleted by a particular user,
Navigate to your SharePoint online site, Click on Site Settings Gear >> Choose "Site Settings"
From the Site settings page, Click on "Recycle bin" from Site Collection Administration. This page gives you all deleted items in the site collection along with deleted by user data.
PowerShell script to search SharePoint online Recycle bin:
How to search SharePoint Online Recycle Bin?
To find all items deleted by a particular user,
#Load SharePoint Online Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" ##Variables for Processing $SiteUrl = "https://crescent.sharepoint.com/sites/Sales/" $AdminUserName="Salaudeen@crescent.com" $DeletedByUserAccount="salaudeen.rajack@crescent.com" #Get the password to connect $Password = Read-host -assecurestring "Enter Password for $AdminUserName" $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($AdminUserName,$Password) Try { #Setup the context $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) $Context.Credentials = $Credentials #Get the site recycle bin $Site = $Context.Site $RecycleBinItems = $Site.RecycleBin $Context.Load($Site) $Context.Load($RecycleBinItems) $Context.ExecuteQuery() #Get all items deleted by particular user in Recycle bin $DeletedByUser = $RecycleBinItems | Where {$_.DeletedByEmail -eq $DeletedByUserAccount} Write-Host "Total Number of Items deleted by user:" $DeletedByUser.Count #format output as table and print to console $DeletedByUser | Select Title, DeletedByEmail, DeletedDate | Format-Table } catch { write-host "Error: $($_.Exception.Message)" -foregroundcolor Red }
SharePoint Online: Search Recycle bin using PowerShell
Reviewed by Salaudeen Rajack
on
July 02, 2016
Rating:

No comments:
Please Login and comment to get your questions answered!