Error when using Remove-SPOSite command on PowerShell

2021-08-27T13:11:29.453+00:00

Hi,

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

SharePoint
SharePoint
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
    2021-09-01T18:34:37.293+00:00

    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 https://yoursharepointdomain.com/sites/oldsite/ -LockState Unlock

    Next, Set yourself as the Owner:
    Set-SPOSite -Identity https://yoursharepointdomain.com/sites/oldsite/ -Owner myemailaddress@tiedtlaw email .com -NoWait

    Lastly, Remove the redirect URL:
    Remove-SPOSite -Identity https://yoursharepointdomain.com/sites/oldsite/

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Elsie Lu_MSFT 9,781 Reputation points
    2021-08-30T06:12:54.237+00:00

    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:

    127486-48.jpg

    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.