Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CherifSy/18cc118211688bb19a53c2f282543322 to your computer and use it in GitHub Desktop.
Save CherifSy/18cc118211688bb19a53c2f282543322 to your computer and use it in GitHub Desktop.
Recreating a site collection using the SPO cmdlets.
. .\PS_SPO_TopOfScript.ps1
# replace these details - parameters for new site collection..
$siteCollectionUrl = "Your site URL here.."
$owner = $username
$storageQuota = 100
$resourceQuota = 30
$localeID = 1033
$timeZoneID = 2 # (GMT London)
if ($connected)
{
Write-Host "Removing site collection $siteCollectionUrl - please wait.."
Remove-SPOSite $siteCollectionUrl -Confirm:$false
Write-Host "Now deleting from recycle bin.."
Remove-SPODeletedSite $siteCollectionUrl -Confirm:$false
Write-Host "Creating new site collection (no template) at $siteCollectionUrl - please wait.."
New-SPOSite -Url $siteCollectionUrl -Owner $owner -StorageQuota $storageQuota -LocaleId $localeID -ResourceQuota $resourceQuota -TimeZoneId $timeZoneID
Disconnect-SPOService
Write-Host "Completed" -ForegroundColor Green
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment