Last active
March 8, 2022 08:34
-
-
Save aflyen/fdd522ead35d6dc8e4456723a98d058f to your computer and use it in GitHub Desktop.
Bulk delete sites from CSV file in 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)" | |
Remove-PnPTenantSite -Url $_.URL -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment