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"
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