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.PowerShellOption 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.comOnce 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 $adminCredentialStep 3: Verify the Connection
To verify you’re connected, run a simple command:
Get-SPOSiteThis 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.comCheck 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.PowerShellStep 2: Connect with Modern Authentication
Connect-SPOService -Url https://yourtenant-admin.sharepoint.comWithout 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

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.