How to move all the items in recycle bin stage 1 to recycle bin stage 2 in SharePoint Online/Office 365/Sharepoint 2010/2013/2016?
Hello SharePointers,
Below are the powershell script to move recycle bin items from stage1 to stage 2.
This would come to us in handy in case if we can to move it on our own rather than depending on the job.
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $Password)
$ctx.ExecuteQuery()
$ctx.Load($ctx.Web)
$recyclebin=$ctx.Web.RecycleBin
$ctx.Load($rb)
$ctx.ExecuteQuery()
Write-Host $ctx.Web.Url ” has ” $recyclebin.Count.ToString() ” items in the recycle bin”
Write-Host “Moving items to the second stage recycle bin…”
$recyclebin.MoveAllToSecondStage()
$ctx.ExecuteQuery()
}
Happy SharePointing 🙂