Monday, June 17, 2019

Steps to Delete sites collections on SharePoint Online using Powershell script by importing CSV file


Steps to Delete sites collections using Powershell script by importing CSV file

$cred = Get-Credential
Connect-SPOService $adminSiteUrl -Credential $cred

$filepath="C:\GK\PowerShell Scripts\Deletion of Site Collections in CSV\Updated Gidc sites.csv"
$CSVData = Import-CSV -path $filepath
$SiteUrl="https://tenant.sharepoint.com/sites/TestSiteUsingAF";

Remove only one site
Remove-SPOSite -Identity $SiteUrl -NoWait
Remove-SPOSite -Identity  $SiteUrl -confirm:$false

Remove multiple sites which are listed CSV
foreach($row in $CSVData)
 {
 write-host "Deleteing Site " + $row.Url
 Remove-SPOSite -Identity $row.Url -confirm:$false
 }

Below command will get all site collections under Bin folder
Get-SPODeletedSite

No comments:

Post a Comment

🚀Microsoft Copilot – Free vs. Licensed vs. Copilot Studio (Complete Guide)

Artificial Intelligence is rapidly transforming workplace productivity. Microsoft’s Copilot ecosystem is at the heart of this shift, but the...