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 email@example.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
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 firstname.lastname@example.org -NoWait
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.
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.
Remove-SPOSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySharePointSite -NoWait
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:
- SharePoint download multiple files + using PnP PowerShell
- SharePoint PnP PowerShell examples (Best 25)
- Delete all items from a SharePoint Online list using PnP PowerShell
- How to connect to Microsoft Teams using PowerShell + 13 Examples
- Create SharePoint Online Modern Page + PnP PowerShell
- Create a communication site in SharePoint using PowerShell
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 the requested operation is not supported for site
Hello Everyone!! I am Bhawana a SharePoint MVP and having about 10+ years of SharePoint experience as well as in .Net technologies. I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools. Now exploring more in SharePoint 2016 🙂 Hope here I can contribute and share my knowledge to the fullest. As I believe “There is no wealth like knowledge and no poverty like ignorance”