Comments? Questions?

Have a look at my GitHub SharePointOnline-ScriptSamples, where you can find this SharePoint script and many others!

You can find all my repositories at PowershellScripts @ GitHub



Imagine that your employee wreaked havoc in all the Sharepoint sites he had access to, randomly deleting files, items, lists. Now you, as an admin, need to restore them. Of course you can do it one by one searching through all the recycle bins, but... there is the Powershell :)

 If you need a variation of the script, just leave a comment, how you think it could be more useful.





The script loops across all site collections' recycle bins and finds all items one user deleted and restores them all.




 Atfer each site the script will ask you if it should proceed to restore the items:


If the item is DELETED BY a specified user, it is registered in a csv file (regardless of whether you decide to restore it or not):

If you decide to restore the items from a given site collection (all or none, you can't select), enter "y" and the script will restore them and print out their names in green.

If it runs into any troubles (e.g. it cannot access site) it will notify you about it in red







Before running the script you need to open the file and enter the correct the data:


# Paths to SDK. Please verify location on your computer. 
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"  
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"  
Add-PSSnapin Microsoft.SharePoint.PowerShell 
# Insert the credentials and the name of the admin site 
$AdminPassword=Read-Host -Prompt "Password" -AsSecureString