Skip to content

Restore-DeletedSite

SharePoint Online: Restores a deleted site collection

#Requires -Version 5.1
#Requires -Modules Microsoft.Online.SharePoint.PowerShell

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$Identity,
    [switch]$NoWait
)

Process {
    try {
        $cmdArgs = @{ ErrorAction = 'Stop'; Identity = $Identity; NoWait = $NoWait }
        Restore-SPODeletedSite @cmdArgs | Out-Null
        [PSCustomObject]@{ Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"; Status = "Success"; Message = "Site '$Identity' restored from recycle bin" }
    }
    catch { throw }
}

URL of the deleted site collection to restore

Off

Continue executing script immediately without waiting

An interactive directory of PowerShell scripts.