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

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

Remove-SPODeletedSite PowerShell cmdlet we use to delete site collection in SharePoint Online PowerShell.

If you are new to PowerShell and want to know how we can use PowerShell in SharePoint Online Office 365 site, then you can read: Steps to connect to SharePoint online site using SharePoint Online Management Shell?

Below is the SharePoint Online PowerShell command I was using.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://onlysharepoint2013-admin.sharepoint.com -credential bijay@xyz.onmicrosoft.com
Remove-SPODeletedSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySite -Confirm:$false

But it gave me below error:

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

Remove-SPOSite Access denied
SharePoint Online PowerShell Remove-SPOSit

Remove-SPOSite Access denied

The problem was that the account I was using within the PowerShell cmdlets.

The account should be a site collection administrator for the 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.

Read some SharePoint PowerShell cmdlets examples:

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

>