As a SharePoint administrator, I’ve found that using PowerShell to manage SharePoint Online can save hours of tedious work. Whether you’re managing SharePoint sites, users, or content such as items or documents, PowerShell provides different cmdlets.
In this tutorial, I will demonstrate various methods for connecting to SharePoint Online using PowerShell.
Using SharePoint Online Management Shell
First, let’s understand how to connect to SharePoint Online using the SharePoint Online Management Shell.
The SharePoint Online Management Shell is Microsoft’s official PowerShell module for SharePoint Online administration.
Follow the steps below:
Step 1: Install the SharePoint Online Management Shell
Before connecting, you’ll need to install the SharePoint Online Management Shell. There are two ways to do this:
Option A: Install via PowerShell Gallery
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Option B: Download and Install Manually
You can also download the SharePoint Online Management Shell from the Microsoft Download Center and run the installer.
Step 2: Connect to SharePoint Online
Once installed, you can connect to a SharePoint Online site by using the following cmdlet.
Connect-SPOService -Url https://yourtenant-admin.sharepoint.com -Credential (Get-Credential)
This command will prompt you for your username and password. Replace “yourtenant” with your actual tenant name.
Connect-SPOService is a PowerShell cmdlet that establishes a connection between your local PowerShell session and your SharePoint Online tenant. This connection is the first crucial step before you can run any SharePoint Online administrative commands.
Think of it as opening the door to your SharePoint Online environment. Without this connection, you simply cannot access it to make changes or retrieve information.
Alternatively, you can also use the cmdlets listed below.
Connect-SPOService -Url https://<tenantname>-admin.sharepoint.com -credential yourusername@<tenantname>.onmicrosoft.com
Once you run the above cmdlets, it will ask you to enter a password like below:

You can also try using the following command:
# Store credentials in a variable
$adminCredential = Get-Credential
# Connect using stored credentials
Connect-SPOService -Url "https://contoso-admin.sharepoint.com" -Credential $adminCredential
Step 3: Verify the Connection
To verify you’re connected, run a simple command:
Get-SPOSite
This should return a list of your SharePoint sites from your Microsoft 365 tenant.

Step 4: Connect With Windows PowerShell ISE
If you want to connect with Windows PowerShell ISE, then you can run the following commands:
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://<tenantname>-admin.sharepoint.com -credential yourusername@<tenantname>.onmicrosoft.com
Check out Turn Off Microsoft Authenticator App in Microsoft 365
Connect with Modern Authentication
Modern authentication is more secure and supports multi-factor authentication (MFA).
Step 1: Install the Required Module
Ensure you have the latest version of the SharePoint Online Management Shell. You can run the below cmdlet to update the SharePoint Online management shell.
Update-Module -Name Microsoft.Online.SharePoint.PowerShell
Step 2: Connect with Modern Authentication
Connect-SPOService -Url https://yourtenant-admin.sharepoint.com
Without specifying credentials, this will open a web-based authentication dialog where you can enter your credentials and complete any multi-factor authentication (MFA) challenges.
Here is a video tutorial that I have recorded for the same purpose.
I hope you now have a complete understanding of how to connect to SharePoint Online using the SharePoint Online Management Shell.
You may also like:
- The property or field Url has not been initialized. It has not been requested or the request has not been executed.
- Connect-SPOService : current site is not a tenant administration site.
- Your Organization’s Policies Don’t Allow You To Share With These Users While Sharing Files In SharePoint Online
- Export and Import SharePoint Online Site as Template using PowerShell

I have worked with Microsoft technologies for more than 18 years, including SharePoint, Microsoft 365 and the Power Platform (Power Apps, Power Automate and Power BI), at companies like HP, TCS and KPIT. I started EnjoySharePoint in 2011 to share the solutions I build in real projects with readers in the United States, Canada, the United Kingdom, Australia, New Zealand and beyond. Microsoft has recognized this work with the Microsoft MVP award 13 times since 2014.