Skip to content

Instantly share code, notes, and snippets.

@aflyen
Last active March 8, 2022 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aflyen/fdd522ead35d6dc8e4456723a98d058f to your computer and use it in GitHub Desktop.
Save aflyen/fdd522ead35d6dc8e4456723a98d058f to your computer and use it in GitHub Desktop.
Bulk delete sites from CSV file in SharePoint Online with PowerShell
# 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)"
Remove-PnPTenantSite -Url $_.URL -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment