How to Restore Deleted Site Collection in SharePoint 2019 using PowerShell

Sathish Nadarajan
 
Solution Architect
April 8, 2020
 
Rate this article
 
Views
1253

Sometimes, we might be deleting the Site Collections from the Central Admin or using the PowerShell scripts.  Mostly, we might be deleting them with full conscious.  But, if we want to restore the deleted site collection, there is no way (as far as my knowledge) from the Central Admin.  But there is a way to restore using PowerShell.

The script is straight forward and can be used with a trick as well.  Let me explain in detail.

Add-PSSnapin "Microsoft.SharePoint.Powershell"

$deletedSite = Get-SPDeletedSite "/sites/MyDeletedSite" 

Restore-SPDeletedSite -Identity $deletedSite

The above script will work fine, when we have only one deleted site.  In my case, I had a small problem.  I had a site collection called “MyDeletedSite” as a TeamSite.  I deleted that from the Central Admin.  Later, I created another site with the same name as “MyDeletedSite” as a Publishing Portal.  Then, again I deleted that also.  Now, I wanted to restore “MyDeletedsite” which I created as a Team Site.  Luckily, the method Get-SPDeletedSite method will give you all the deleted sites with the same name.  From that, we need to identify which site we want to restore.

Add-PSSnapin "Microsoft.SharePoint.Powershell"

$deletedSite = Get-SPDeletedSite "/" 

$tobeRestored = $deletedSite[1] # The site which we wanted to restore

Restore-SPDeletedSite -Identity $tobeRestored

Happy Coding,

Sathish Nadarajan.

 

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment