共用方式為


February CSOM Update for SharePoint Online - Deleting Items from the Second Stage Recycle Bin

The February CSOM update for SharePoint Online which is now available provides the ability to empty the Second-Stage Recycle Bin for a Site Collection, here is a short sample of how to do this using PowerShell, simply update the highlighted values and execute!

#Add references to SharePoint client assemblies and authenticate to Office 365 site
Add-Type -Path "D:\Assemblies\Microsoft.SharePoint.Client.dll"
Add-Type -Path "D:\Assemblies\Microsoft.SharePoint.Client.Runtime.dll"
$Username = "admin@tenant.onmicrosoft.com"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$Site = "https://tenant.sharepoint.com/sites/testsite"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)
$Context.Credentials = $Creds

#Remove all items from the second stage recycle bin
$Context.Site.RecycleBin.DeleteAllSecondStageItems()
$Context.ExecuteQuery()

Brendan Griffin - @brendankarl