You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the users of a customer had, by accident, deleted all files from a specific SharePoint. I was able to retrieve these files in the Recycle Bin. I know how to restore these files manually, but this user had deleted all items (again by accident), and it containts thousands of files.
I didn't want to restore all of these files by hand, so I've found which I thought it would help me restore the files automatically. This script worked just fine in two of my test tenants, but although the script gives me no errors when running it for the customers's tenant, no items deleted by this specific user and/or on this specific date are being restored. To be sure, I've added the script I've used below:
# PowerShell script to restore SharePoint items from the recycle bin for a specific date and user
# Set the date for items to be restored
$specificDate = Get-Date -Date "01-08-2024" -Format "dd-MM-yyyy"
# Set the email address of the user whose items need to be restored
$userEmail = "[email protected]"
# Connect to the SharePoint site
Connect-PnPOnline -Url "https://_____-portal1.sharepoint.com/" -Interactive
# Get all items that were deleted on the specific date and by the specific user
$itemsToRestore = Get-PnPRecycleBinItem | Where-Object {
$_.DeletedDate.Date -eq $specificDate.Date -and
$_.DeletedByEmail -eq $userEmail
}
# Restore each item
foreach ($item in $itemsToRestore) {
Get-PnPRecycleBinitem -RowLimit 3000 | -Restore-PnPRecycleBinItem -Force
}
# Print a success message
Write-Host "Items deleted by $userEmail on $specificDate have been restored."
Keep in mind that this specific SharePoint is a very old SharePoint (portal sharepoint) and still has an old structure to it, compared to newer teamsites. Not sure if this could matter, but good to know.
Hopefully somebody is able to help me out, would love to know what I could be doing wrong, or what tweaks I might have to add to my PowerShell script.
Thanks in advance! Kind regards,
Koen Stronkhorst
The text was updated successfully, but these errors were encountered:
Hi there!
One of the users of a customer had, by accident, deleted all files from a specific SharePoint. I was able to retrieve these files in the Recycle Bin. I know how to restore these files manually, but this user had deleted all items (again by accident), and it containts thousands of files.
I didn't want to restore all of these files by hand, so I've found which I thought it would help me restore the files automatically. This script worked just fine in two of my test tenants, but although the script gives me no errors when running it for the customers's tenant, no items deleted by this specific user and/or on this specific date are being restored. To be sure, I've added the script I've used below:
Keep in mind that this specific SharePoint is a very old SharePoint (portal sharepoint) and still has an old structure to it, compared to newer teamsites. Not sure if this could matter, but good to know.
Hopefully somebody is able to help me out, would love to know what I could be doing wrong, or what tweaks I might have to add to my PowerShell script.
Thanks in advance! Kind regards,
Koen Stronkhorst
The text was updated successfully, but these errors were encountered: