Forum Discussion
PeteWalburn
May 19, 2025Copper Contributor
Restore specific items from SharePoint recycle bin
Hi,
I would like to check in the SharePoint Recycle Bin if an item with a specific value has been deleted and restore just that item.
I this possible? I was trying using Power Automate and the Send an HTTP request to SharePoint, but am not sure how to narrow down the request.
Any help is much appreciated,
Pete
1 Reply
- grant_jenkinsIron Contributor
The below example allows you to find List items that have been deleted with a particular Title and restores them. Note that in my example it's finding List Items (not Documents) with "Item XXXX" anywhere in the title. You might want to change this to the below for an exact match.
-eq "Your full title"Full code below.
# Parameters $siteUrl = "https://YOUR_TENANT.sharepoint.com/sites/YOUR_SITE" # 1) Connect to the site Connect-PnPOnline -Url $siteUrl -ClientId "YOUR_CLIENT_ID" -Interactive # 2) Get all recycle-bin items (increase RowLimit if needed) filtered on Title $allRecycled = Get-PnPRecycleBinItem -RowLimit 5000 | Where {$_.ItemType -eq "ListItem" -and $_.Title -like "*Item XXXX*"} # 3) Restore each $allRecycled | ForEach-Object { try { $title = $_.Title Restore-PnPRecycleBinItem -Identity $_ -Force Write-Host "Restored:" $title } catch { Write-Warning "Failed to restore $_.Title : $_" } }