Add Site Collection Administrator Using Powershell In SharePoint Online

This blog will help you to understand how to add a site collection administrator using SharePoint Online Management Shell.

Just consider, you have created one site collection in the SharePoint Online and it started provisioning. After a few minutes, you realized that the site provisioning doesn't happen properly and it says "Access Denied" like the below image.

Add Site Collection Administrator Using Powershell In SharePoint Online 
As a SharePoint Administrator, first, we will look into the logs to find the root cause of why it has not added any user on the site. Then, we will try to add the user in the Site collection administrator using Admin Center but sometimes, when we add a user using GUI mode, it will not reflect properly and the user may get "Access Denied" repeatedly.
 
Add Site Collection Administrator Using Powershell In SharePoint Online
 
So, our next step would be to open the SharePoint Online Management Shell to add the user as a Site Collection Administrator.
  1. # To connect your shell to the SharePoint Online  
  2. Connect-SPOService -URL https://tenant-admin.sharepoint.com  
Here, I always prefer to enter the credentials in the browser mode because in some cases, the organization may enable the Multi-Factor Authentication (MFA). This method will help you to resolve your MFA.
 
Add Site Collection Administrator Using Powershell In SharePoint Online 
  1. Set-SPOUser -Site https://tenant.sharepoint.com/sites/sitename -LoginName [email protected] -IsSiteCollectionAdmin $true  
Add Site Collection Administrator Using Powershell In SharePoint Online
 
This command will set the user as a Site Collection Administrator in the respective site collection and once you try to access that site collection, it will allow you to access it and then go to site setting -> site permission and check the user permission,
 
Add Site Collection Administrator Using Powershell In SharePoint Online 
 
You may get "None", which means you are not a member of the site collection. You are a site collection administrator with high privilege.