Remove-SPOSite Access denied. You do not have permission to perform this action or access this resource in SharePoint Online

In this PowerShell SharePoint tutorial, we will discuss how to fix the error, Remove-SPOSite Access denied You do not have permission to perform this action or access this resource. The error remove-sposite : access is denied comes while trying to delete and restore a SharePoint site collection using PowerShell in SharePoint Online.

Recently I was trying to delete and restore a site collection using PowerShell in SharePoint Online. While running the SharePoint PowerShell command, it gave an error as Remove-SPOSite Access denied You do not have permission to perform this action or access this resource.

Below is the SharePoint Online PowerShell command I was using to delete a SharePoint site.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

Connect-SPOService -Url https://onlysharepoint2013-admin.sharepoint.com -credential bijay@onlysharepoint2013.onmicrosoft.com

Remove-SPOSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySite -Confirm:$false

But it gave me the below error:

Remove-SPOSite Access denied You do not have permission to perform this action or access this resource.

Remove-SPOSite Access denied
remove-sposite : access is denied

Remove-SPOSite Access denied

The problem was that the account I was using with in the PowerShell cmdlets.

The account should be a site collection administrator for the SharePoint site which you are going to delete. After I add the user to the site collection administrator, I was able to delete the site collection using the Remove-SPOSite PowerShell command in SharePoint Online.

We can also use the PowerShell Set-SPOSite command to set a user as an owner of the SharePoint site like below:

Set-SPOSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySite -Owner bijay@onlysharepoint2013.onmicrosoft.com -NoWait

Remove-SPOSite

Here I have used the Remove-SPOSite PowerShell command to delete a SharePoint site using SharePoint Online management shell.

This command will move the SharePoint site collection to the SharePoint Online recycle bin. And you can see the recycle bin from the SharePoint Online admin center.

See also  SharePoint Online storage limits (Detailed Guide)

Open SharePoint Online admin center, expand Sites -> Deleted sites. Here you can see the SharePoint site which you have deleted by using the Remove-SPOSite PowerShell cmdlets.

Example:

Remove-SPOSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySharePointSite -NoWait

Remove-SPODeletedSite

The error can also come while running the Remove-SPODeletedSite PowerShell cmdlet.

Remove-SPODeletedSite PowerShell cmdlet will remove a deleted SharePoint site collection from the recycle bin permanently.

Remove-SPODeletedSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySharePointSite

Once you run the above command, the SharePoint site will be removed from the recycle bin.

Read some SharePoint PowerShell cmdlets examples:

I hope this might help someone to solve the error: Remove-SPOSite Access denied You do not have permission to perform this action or access this resource in SharePoint Online. I hope it fixes the below errors:

  • remove-sposite : access is denied
  • remove-sposite access denied
  • remove-sposite : the requested operation is not supported for site
  • get-spouser access denied
  • remove-sposite
  • remove-sposite the requested operation is not supported for site
>