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 email@example.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
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:
- Upload document using PowerShell Remotely
- Upload documents from a network drive to SharePoint 2013 or SharePoint 2016 Server document library using PowerShell
- SharePoint Online storage limits
- How to send email using PowerShell in Office 365
- Create a web application in SharePoint 2016 using PowerShell
- Working with PowerShell Date Command (Get-Date)
- Working with PowerShell in SharePoint Online/2016/2013
- PowerShell Basics: A Beginners Guide
- What is a PowerShell variable
- Exception calling ExecuteQuery with 0 argument(s): Unable to connect to the remote server
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.
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”