logo
search
Permission & Access Issues

How to Add a User to All SharePoint Online Sites Using PowerShell

Amos GikundaAmos Gikunda Oct 10, 2026 868 views

Question details

The user needs to programmatically assign a specific user or administrator account to all SharePoint Online site collections.

Add a User to All SharePoint Online Sites with PowerShell
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.
Before you start

Ensure you have installed the SharePoint Online Management Shell and possess SharePoint Administrator or Global Administrator credentials to connect to your tenant via PowerShell.

Solution 1Recommended

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.

1
Launch PowerShell

Open the SharePoint Online Management Shell on your computer with Administrator privileges.

2
Connect to SharePoint Admin Center

Execute the command Connect-SPOService -Url https://[yourtenant]-admin.sharepoint.com and log in with your global admin credentials.

3
Retrieve All Site Collections

Use the Get-SPOSite -Limit All cmdlet to fetch a list of all site collections within your tenant.

4
Apply Permissions in a Loop

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.

Enumerate and Assign Users via PowerShell Script
Need Help Customizing Scripts?: If a standard community script does not meet your specific requirements, post your question in Microsoft Q&A under the SharePoint Development tag for custom scripting assistance.
Free Microsoft Office alternative

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. 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install the Software: Run the installer and follow the quick on-screen instructions to set up the office suite.
  3. 3. Open Your Files: Launch WPS Office and directly open your existing Word, Excel, and PowerPoint files without any format conversion.
  4. 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.
Fully compatible with Microsoft Office formats (.docx, .xlsx, .pptx)Built-in cloud storage for hassle-free document sharing and collaborationFree and lightweight office suite for Windows, Mac, iOS, and AndroidFamiliar tabbed user interface requiring zero learning curve for seamless migration
microsoft office alternative - wps office

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.