Forum Discussion
DiVojich
Sep 26, 2019Brass Contributor
Restore items
On September 23rd (3 days ago) a user deleted a large number of files from SharePoint online. Files are still in 1st Recycle Bin. My question is: What would be the most simple command to restore t...
cvgshubh
Aug 13, 2020Copper Contributor
1)Run windows Power shell as administrator
2)Install this module
Install-Module SharePointPnPPowerShellOnline
3)Connecting to a specific site with the help of its URL
Note :- dont use '<>' braces any where
Connect-PnPOnline -Url <site URL>
Enter Global admin credentials when it gives you a prompt.
4)to check connection run below command it will show the list of deleted items of the this particular site
Get-PnPRecycleBinItem
5) Defining date variables
$today = (Get-Date)
$date1 = $today.date.addDays(-3)
$date2 = $today.date.addDays(0)
6)Run this command to restore the files as the date variable values like above -3 and 0 , so that the restored files are backed to these many days only and not includes all the files deleted by hte user over all
Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $date2 -and $_.DeletedDate -lt $date1) -and ($_.DeletedByEmail -eq 'xyz@domain.com' )} | Restore-PnPRecycleBinItem -Force
In emergency cases If you wish to restore all the files and folders deleted by a specific user from the specific site
Please repeate the obove steps 1-4 and then give the command in the below 5th step
5) Get-PnPRecycleBinItem -FirstStage | ? DeletedByEmail -eq 'xyz@domain.com' | Restore-PnpRecycleBinItem -Force
Wait for few minutes because we are restoring files in bulk
2)Install this module
Install-Module SharePointPnPPowerShellOnline
3)Connecting to a specific site with the help of its URL
Note :- dont use '<>' braces any where
Connect-PnPOnline -Url <site URL>
Enter Global admin credentials when it gives you a prompt.
4)to check connection run below command it will show the list of deleted items of the this particular site
Get-PnPRecycleBinItem
5) Defining date variables
$today = (Get-Date)
$date1 = $today.date.addDays(-3)
$date2 = $today.date.addDays(0)
6)Run this command to restore the files as the date variable values like above -3 and 0 , so that the restored files are backed to these many days only and not includes all the files deleted by hte user over all
Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $date2 -and $_.DeletedDate -lt $date1) -and ($_.DeletedByEmail -eq 'xyz@domain.com' )} | Restore-PnPRecycleBinItem -Force
In emergency cases If you wish to restore all the files and folders deleted by a specific user from the specific site
Please repeate the obove steps 1-4 and then give the command in the below 5th step
5) Get-PnPRecycleBinItem -FirstStage | ? DeletedByEmail -eq 'xyz@domain.com' | Restore-PnpRecycleBinItem -Force
Wait for few minutes because we are restoring files in bulk