Managing SharePoint Online through the browser is fine for day-to-day administration, but when you need to automate repetitive tasks, bulk operations, or reporting, PowerShell becomes essential.
With SharePoint Online PowerShell, Microsoft 365 administrators can quickly connect to their SharePoint tenant, retrieve site collections, manage sharing settings, configure storage limits, and automate administrative tasks efficiently.
In this guide, you will learn how to:
Important: Microsoft Graph PowerShell currently does not fully support SharePoint Online administration. While some SharePoint-related cmdlets exist in the beta Microsoft Graph PowerShell module, they are not considered production-ready yet. For stable and supported SharePoint administration automation, the Microsoft.Online.SharePoint.PowerShell module remains the recommended option.
Before connecting to SharePoint Online using PowerShell, ensure the following requirements are met:
Your account should have one of the following roles:
Without sufficient permissions, connection attempts or administrative cmdlets may fail.
The SharePoint Online Management Shell works best with:
You can check your PowerShell version using:
$PSVersionTable.PSVersion
The PowerShell module connects directly to Microsoft 365 services, so internet access is required.
The module is installed from the PowerShell Gallery. Ensure PSGallery access is not blocked by proxy or firewall restrictions.
Microsoft provides the Microsoft.Online.SharePoint.PowerShell module for managing SharePoint Online.
Run the following command to install the module:
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
If prompted to trust the repository, type: A [Select to ALL] and press Enter.
If you do not have administrative privileges on your machine, use:
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
To update the module later, run:
Update-Module Microsoft.Online.SharePoint.PowerShell
After installation, use the following cmdlet to connect to your SharePoint Online tenant:
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com
Replace <tenant> with your Microsoft 365 tenant name.
Example:
Connect-SPOService -Url https://contoso-admin.sharepoint.com
After running the command:
Once authenticated successfully, your PowerShell session will connect to SharePoint Online.
Many administrators accidentally connect using the regular SharePoint URL instead of the admin URL.
❌ Incorrect:
Connect-SPOService -Url https://contoso.sharepoint.com
✅ Correct:
Connect-SPOService -Url https://contoso-admin.sharepoint.com
The -admin portion is mandatory.
To verify whether the SharePoint Online PowerShell module is installed successfully, run:
Get-Module -ListAvailable Microsoft.Online.SharePoint.PowerShell
If installed correctly, PowerShell displays module details similar to:
You can also check available SharePoint cmdlets using:
Get-Command -Module Microsoft.Online.SharePoint.PowerShell
This lists all SharePoint Online PowerShell commands available in the module.
Once connected, you can retrieve all SharePoint Online site collections using:
Get-SPOSite
This command displays details such as:
For reporting purposes, administrators often export site details to CSV:
Get-SPOSite | Select-Object Url, Owner, StorageUsageCurrent, Template |
Export-Csv "C:\Reports\SharePointSites.csv" -NoTypeInformation
This creates a SharePoint Online site inventory report.
After completing administrative tasks, disconnect the PowerShell session using:
Disconnect-SPOService
Disconnecting is considered a good security practice, especially on shared or administrative systems.
Many Microsoft 365 administrators wonder whether Microsoft Graph PowerShell can fully replace the SharePoint Online Management Shell.
Currently:
Because of this, the Microsoft.Online.SharePoint.PowerShell module remains the primary and supported option for SharePoint Online automation.
For tasks such as:
the SharePoint Online Management Shell is still the recommended solution.
The SharePoint Online PowerShell module is a Microsoft-provided PowerShell module used to manage SharePoint Online administrative tasks.
The following cmdlet connects to SharePoint Online: Connect-SPOService
Not fully. SharePoint administration cmdlets in Microsoft Graph PowerShell are currently limited and mostly available only in beta versions.
You typically need: SharePoint Administrator role or Global Administrator role
Use: Get-SPOSite
Use: Disconnect-SPOService
The SharePoint Online Management Shell remains one of the most important PowerShell modules for Microsoft 365 administrators. Whether you want to retrieve SharePoint site collections, automate reporting, configure sharing settings, or manage SharePoint storage, PowerShell significantly simplifies administration.
Although Microsoft Graph PowerShell is becoming the standard for many Microsoft 365 workloads, SharePoint Online administration still primarily relies on the Microsoft.Online.SharePoint.PowerShell module because Graph-based SharePoint management cmdlets are still limited and not production-ready.
For administrators looking to automate SharePoint Online efficiently today, the SharePoint Online PowerShell module remains the best-supported and most reliable option.
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex