Last active
March 8, 2022 08:34
-
-
Save aflyen/38d4dd33cfd20b5fbecb633cd20da37b to your computer and use it in GitHub Desktop.
Bulk delete modern team sites from SharePoint Online with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read CSV file with a column "URL" including the full URL to the sites to be deleted | |
$Sites = Import-Csv .\sites.csv | |
# Connect to admin site | |
Connect-PnPOnline -Url https://contoso-admin.sharepoint.com | |
# Delete all sites to recycle bin | |
$Sites | ForEach-Object { | |
Write-Host "Remove: $($_.URL)" | |
$Site = Get-PnPTenantSite -Identity $_.URL | |
Remove-PnPMicrosoft365Group -Identity $Site.GroupId | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment