Saturday, October 5, 2019

Permanently Delete a SharePoint Site Collection

#Permanently Delete a SharePoint Site Collection.

#To begin, you will need to load the SharePoint Online module to be able to run commands in PowerShell. You must also replace the url "https://anjantech-admin.sharepoint.com" and use your SharePoint administrative site.

Import-Module Microsoft.Online.Sharepoint.PowerShell

$credential = Get-credential
Connect-SPOService -url https://anjantech-admin.sharepoint.com -Credential $credential

#This command will delete the SharePoint site collection. You must replace the url "https://anjantech.sharepoint.com/sites/SiteCollectionName" with your Sharepoint Online URL and use the Site Collection Name that is to be deleted for this script to work properly.

Remove-SPOSite -Identity https://anjantech.sharepoint.com/sites/SiteCollectionName -NoWait

#This command will pause the script for 20 seconds before proceeding.
Start-Sleep -s 20

#This script will permanently delete the SharePoint site collection after it is sent to the SharePoint Site Recycle Bin. You must replace the url “https://anjantech.sharepoint.com/sites/SiteCollectionName” with your Sharepoint Online URL and use your Site Collection Name that is to be permanently deleted for this script to work properly.

Remove-SPODeletedSite -Identity https://anjantech.sharepoint.com/sites/SiteCollectionName

No comments:

Post a Comment