question

Srini-4386 avatar image
0 Votes"
Srini-4386 asked WeyHo-3859 published

How can you restore files deleted by a particular user within a specific time using powershell ?

How can you restore files deleted by a particular user within a specific time? using powershell

Please advise

office-sharepoint-onlineoffice-sharepoint-server-administration
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sorry, I usually prefers date1 be the older date and date 2 the newer date. If you set it this way, greater than date "-gt" and Less than date "-lt" dates the other way around between "date1" and "date2".

0 Votes 0 ·
MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered WeyHo-3859 published

Below is my sample script for you:

 $date1=get-date("08/21/2020")
 $date2=get-date("08/11/2020")
 Connect-PnPOnline https://tenant.sharepoint.com/sites/michael
 Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $date2 -and $_.DeletedDate -lt $date1) -and ($_.DeletedByEmail -eq 'john@contoso.com')} | Restore-PnpRecycleBinItem -Force

Reference: restore-recycle-bin-sharepoint-online-with-powershell
powershell-recursive-folder-restore



If the response is helpful, please click "Accept Answer" and upvote it.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks a lot Mike. It saves my time.

0 Votes 0 ·

Please help the PowerShell command is performed. but in the backend, the files are still in the recycle bin
83735-image.png

here is a screenshot attached. also, i have tried it with both modules at a time with one but still the command runs but the file is still in the bin

Install-Module -Name SharePointPnPPowerShellOnline
Install-Module -Name PnP.PowerShell



although this works
Get-PnPRecycleBinItem | Where { $_.DeletedByEmail -eq "amit@mstestgigmosamyad.onmicrosoft.com"} | Restore-PnpRecycleBinItem -Force

but cant customize dates

0 Votes 0 ·
image.png (77.8 KiB)

Sorry, I usually prefers date1 be the older date and date 2 the newer date. If you set it this way, greater than date "-gt" and Less than date "-lt" dates the other way around between "date1" and "date2".

0 Votes 0 ·
ehendersonT17 avatar image
0 Votes"
ehendersonT17 answered

Hi Mike

I notice the date is in US format will I need to amend it to UK format for this to work on my SPO site?

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.