Skip to content

Instantly share code, notes, and snippets.

@Windos
Created May 26, 2020 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Windos/c0fc6b98c55330767c3de4294f425f50 to your computer and use it in GitHub Desktop.
Save Windos/c0fc6b98c55330767c3de4294f425f50 to your computer and use it in GitHub Desktop.
Deleted a *very* large directory in SharePoint Online? Restore the files en masse with the SPO PnP Module
# Needs the SharePoint Online PnP module, install if haven't got it already:
# Install-Module SharePointPnPPowerShellOnline
$Uri = 'https://tenant.sharepoint.com/sites/Common'
Connect-PnPOnline -Url $Uri -UseWebLogin
$DeletedAt = (Get-Date -Day 24 -Month 05 -Hour 0 -Minute 0 -Second 0)
$DeletedBy = 'first.last@tenant.com'
$DeletedItems = Get-PnPRecycleBinItem
$DeletedItems.Where({$_.DeletedByEmail -eq $DeletedBy -and $_.DeletedDate -gt $DeletedAt}) |
Restore-PnpRecycleBinItem -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment