Remove Deleted Site Collections from SharePoint Online

Cls

Write-Host "Remove Deleted Site Collections"
Write-Host "Password Please :"


#Set-ExecutionPolicy RemoteSigned


$username = "gaurav@goyal.com"
$password=Read-Host -Prompt "Password" -AsSecureString;


$siteAdminURL = "<<Main Tenent URL Here>>"


Import-Module Microsoft.Online.SharePoint.PowerShell –DisableNameChecking


#$securePassword = ConvertTo-SecureString $password –AsPlainText –force


$securePassword=$password


$O365Credential = New-Object System.Management.Automation.PsCredential($username, $securePassword)


Connect-SPOService -Url $siteAdminUrl -Credential $O365Credential

Get-SPODeletedSite | foreach {
Write-host "Deleting " $_.Url
Remove-SPODeletedSite –Identity $_.Url –Confirm:$false
}
Disconnect-SPOService
Write-Host "Removed Site Collections"

Comments

Popular Posts

SharePoint Interview Questions and Answers

Download Infopath Form Templates

How to get current logged user information using JavaScript ?

Steps to set Form based authentication (FBA) for SharePoint 2010

SharePoint Interview Questions and Answers II

Get List Items - JavaScript

Change Language for current user with JSOM in SharePoint Online

Cross Site List Rollup Web Part for SharePoint 2010

Hide Recently Modified Items

SharePoint 2010 CSS Chart