How to Add a User to All SharePoint Online Sites Using PowerShell
Question details
The user needs to programmatically assign a specific user or administrator account to all SharePoint Online site collections.

- Product
- Microsoft SharePoint Online
- Device & OS
- not provided
- Scenario
- Assigning site collection administrator or user permissions in bulk across a SharePoint Online environment.
- Observed behavior
- Global administrator rights do not automatically grant direct access permissions to every individual SharePoint site collection.
Ensure you have installed the SharePoint Online Management Shell and possess SharePoint Administrator or Global Administrator credentials to connect to your tenant via PowerShell.
Enumerate and Assign Users via PowerShell Script
Use a custom PowerShell script to loop through all SharePoint site collections and assign the designated user as a Site Collection Administrator.
Because Global Admin rights do not inherently provide access to all site collections, administrators rely on custom PowerShell loops to grant access. Community-tested scripts, such as those found on SharePoint Diary, can effectively automate this process.
Please note that Microsoft does not officially support or guarantee third-party scripts. Always review the code carefully and execute it in a staging or test environment before running it in production.
Open the SharePoint Online Management Shell on your computer with Administrator privileges.
Execute the command Connect-SPOService -Url https://[yourtenant]-admin.sharepoint.com and log in with your global admin credentials.
Use the Get-SPOSite -Limit All cmdlet to fetch a list of all site collections within your tenant.
Iterate through the retrieved sites and use the Set-SPOUser -Site $site.Url -LoginName "user@domain.com" -IsSiteCollectionAdmin $True command to grant access to the target account.

Simplify Team Collaboration with WPS Office
While managing Microsoft environments like SharePoint often requires complex PowerShell scripts, day-to-day document collaboration should be effortless. WPS Office is a free, lightweight alternative to Microsoft Office that provides a seamless user experience, built-in cloud capabilities, and excellent format compatibility for all your business needs.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install the Software: Run the installer and follow the quick on-screen instructions to set up the office suite.
- 3. Open Your Files: Launch WPS Office and directly open your existing Word, Excel, and PowerPoint files without any format conversion.
- 4. Collaborate in the Cloud: Sign in to your WPS account to sync your documents to the cloud and easily share links with your team.

Frequently Asked Questions
Why doesn't a Global Administrator have access to all SharePoint sites by default?
In Microsoft 365, Global Administrator rights allow you to manage administrative settings at the tenant level. However, for security and privacy reasons, this role does not automatically grant explicit permissions to view content or manage individual SharePoint site collections.
Is it safe to use third-party PowerShell scripts from blogs for SharePoint administration?
While scripts from reputable community sources like SharePoint Diary are widely used by IT professionals, Microsoft does not officially support them. You should always read through the script to understand what each command does and test it on a few non-critical sites before applying it to your entire tenant.
What PowerShell module do I need to manage SharePoint Online permissions?
You must install the SharePoint Online Management Shell. This official Microsoft module contains the specific cmdlets (like Connect-SPOService, Get-SPOSite, and Set-SPOUser) required to remotely administer your SharePoint environment.




