Error when using Remove-SPOSite command on PowerShell



I'm working with Sharepoint Online, since past year I was creating Sharepoint sites from a personal powershell script, using PnP and Sharepoint modules.

It was working fine but since last week I'm getting this error:

Remove-SPOSite : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I tried it with differents accounts (all Global administrators), on differents sites and in differents tenants, but the error keeps there.
Also, all the other commands are working fine, including Remove-SPODeletedSite.

Could have it been an update on Sharepoint Online? Is there someone else with the same problem?

How can I solve this?

PD: I need to use this command, cause I create sites from a template, so then I have to change the url and reuse the original when I run the script again

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,078 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
0 comments No comments
{count} votes

Accepted answer
  1. Simone Sessler 91 Reputation points

    Thank you for all the comments on this thread! I was able to finally successfully remove my redirect URL following these steps:

    First, Unlock the site:
    Set-SPOSite -LockState Unlock

    Next, Set yourself as the Owner:
    Set-SPOSite -Identity -Owner myemailaddress@tiedtlaw email .com -NoWait

    Lastly, Remove the redirect URL:
    Remove-SPOSite -Identity

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Elsie Lu_MSFT 9,781 Reputation points

    Hi @Leonardo Garcia | Consultores en IT ,

    Can you manually delete the site in the Admin center? Has your tenant recently created a retention policy?

    You can go to the Admin center to check whether you can manually delete the site. If there is a retention policy, you can see the following prompt:


    Please refer to this thread for more information about how to solve this issue:
    This site has a compliance policy set to block deletion

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.