I have a site which has site policy associated.

enter image description here

based on my policy site is closed and marked as read-only.

When I try to delete the site from Admin got an error "Couldn't delete site"

enter image description here

One of the possible way to delete the site is, first Open the site from Site Closure and Deletion and then delete. Is there any other way I can delete the site without opening?

Is there CSOM API which with which I can open the site?


You could delete the site by PowerShell command “Remove-SPOsite”.

There is PowerShell script for your reference.

#Variables for processing

$AdminSiteURL = "https://tenantname-admin.sharepoint.com/"

$AdminName = "username@tenantname.onmicrosoft.com"

$SiteCollURL = "https://tenantname.sharepoint.com/sites/Sales"

#Credentials to connect 

$SecurePWD = ConvertTo-SecureString "Password" –asplaintext –force  

$Credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $AdminName, $SecurePWD

#Connect to SharePoint Online

Connect-SPOService -url $AdminSiteURL -credential $Credential

#Delete SharePoint Online Site Collection

Remove-SPOSite -Identity $SiteCollURL -NoWait -Confirm:$false

Write-Host "Site collection has been deleted!"

For more detailed information, refer to the article below.

SharePoint Online: Delete Site Collection using PowerShell.

| improve this answer | |

In order to delete the site I had to first Open the site.

    using (ClientContext clientContext = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(url, <ClientID>, <ClientSecret>))
        var web = clientContext.Site.RootWeb;


    using (var clientContext = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(
                                    , <ClientID>
                                    , <ClientSecret>))
        var tenant = new Tenant(clientContext);

        var removeSite = tenant.RemoveSite(url);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.