Wednesday, January 27, 2016

Restore a Site Collection using PowerShell

Restoring the site collection once it gets deleted inadvertently.

You need the full URL of the site collection which you want to restore back to start. 
Step1 : For Example, I have a root level site collection having full URL as "http://<<host name>>:10000".
You  can execute Get-SPSite cmdlet to get the site object.
 $mysite = Get-SPSite http://<<host name>>:10000
Step2: You can print the GUID of that site by using "id" property of that object in last step.
PS C:\Users> $
Step 3: Then you can use "Get-SpDeletedSite" cmdlet with the id as a parameter to confirm the other details of that site collection such as path and deletion time.
PS C:\Users\> Get-SPDeletedSite $
WebApplicationId   : 740953c9-7041-4130-994a-7d85864975d3
DatabaseId         : 78e0f455-c59d-4404-83c7-085309762fdc
SiteSubscriptionId : 00000000-0000-0000-0000-000000000000
SiteId             : 7044efc1-786f-493b-b3d5-0056add40bb9
Path               : /
DeletionTime       : 1/26/2016 9:40:22 PM
Step 4: Last step is to run "Restore-SPDeletedSite" cmdlet with the "-Identity" parameter. You have to pass on the same id or GUID which you got in last steps. Press 'Y' for confirmation.
PS C:\Users> Restore-SPDeletedSite -Identity $
Are you sure you want to perform this action?
Performing operation "Restore-SPDeletedSite" on Target "/".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):Y
After execution of step4, your site collection would get restored back.

1 comment: