#********** Create multiple Site Collections from .csv file *********************************************
#csv file path
$csvfile = 'C:\doc\CreateSiteCollections.csv'
#O-365 site url and Credential
Connect-SPOService -Url https://ajay-admin.sharepoint.com -Credential [email protected]
Import-Csv $csvfile |
where {
Write-Host "Creating Site Collection: " $_.URL
New-SPOSite -Owner $_.Owner -StorageQuota $_.StorageQuota -Url $_.URL -NoWait -ResourceQuota $_.ResourceQuota -Template $_.Template -TimeZoneID $_.TimeZoneID -Title $_.Title -LocaleID $_.Language
}
#********** delete multiple Site Collections from .csv file *********************************************
$csvfile = 'C:\doc\DeleteSiteCollections.csv'
Connect-SPOService -Url https://ajay-admin.sharepoint.com -Credential [email protected]
Import-Csv $csvfile |
where { Write-Host "Deleting "$_.URL
remove-sposite –identity $_.URL -Confirm:$False
Write-Host "Moved to recycle bin"
remove-spodeletedsite –identity $_.URL -Confirm:$False
Write-Host "Removed from recycle bin"
}| Owner | StorageQuota | Url | ResourceQuota | Template | TimeZoneID | Title | Language |
| [email protected] | 20480 | https://xyz.sharepoint.com/sites/admin | 300 | STS#0 | 4 | Admin | 1033 |
Delete site collection pass only site collection Url column
