How to Connect to SharePoint Online Using PowerShell?

You can use SharePoint Online Management Shell to connect to SharePoint Online using PowerShell.

This PowerShell tutorial will show us how to download and install the SharePoint online management shell and how to connect to SharePoint Online using PowerShell step by step.

What is SharePoint Online Management Shell

SharePoint Online Management Shell is a tool that helps you manage your SharePoint Online environment more efficiently.

It’s like a command center where you can execute commands to perform various tasks, such as configuring settings, managing users, and monitoring your SharePoint Online sites.

Download and Install SharePoint Online Management Shell

Now, I will tell you how to download and install SharePoint Online Management Shell.

Follow the below steps to install SharePoint Online Management Shell:

1. Open any browser and download SharePoint Online Management Shell from the MSDN URL. Choose the language and click on Download.

what is SharePoint online management shell

2. Then SharePoint Online Management Shell downloads in our local system. After downloading, double-click the file, check “I accept the terms in the License Agreement” and click Install.

How to Connect to SharePoint Online from PowerShell

3. Click on Finish.

How do I Connect to a SharePoint online site using PowerShell

This way, you can download and install SharePoint Online Management Shell.

How to Connect SharePoint Online Management Shell?

1. Once you’ve finished installing it, you can search for “SharePoint Online Management Shell” on your Windows system. You’ll find the tool. Open it from there.

How to Connect to SharePoint Online PowerShell

2. After that, you can see the below command prompt box will open.

How to connect to SharePoint Online using PowerShell

3. Then, put the below PowerShell script into the command prompt. Then click enter.

Connect-SPOService -Url https://szg52-admin.sharepoint.com/ -Credential MiriamG@szg52.onmicrosoft.com
Manage SharePoint Online by using Windows PowerShell

4. If you do not provide the SharePoint Online admin site URL, you will get an error like the one below:

Connect-SPOService: Current site is not a tenant administration site error in SharePoint Online Office 365 Site.

Otherwise, it will ask for your credentials like the one below. Provide the SharePoint user credentials and click on OK.

PowerShell  Connect to SharePoint Online

Once it is connected successfully, we can run SharePoint online PowerShell cmdlets.

How to Connect to SharePoint Online Using PowerShell [Windows PowerShell ISE]

We can connect to SharePoint Online Microsoft 365 sites using Windows PowerShell ISE. For that, follow the below steps:

1. Search for “Windows PowerShell ISE” in your window. Click on Open.

How to connect PowerShell to SharePoint Online

2. Then, put the below PowerShell script into the Windows PowerShell ISE. Then Click the Run Script button.

Connect-SPOService -Url https://szg52-admin.sharepoint.com/ -Credential MiriamG@szg52.onmicrosoft.com
How to connect to SharePoint Online Admin using PowerShell

3. After that, one dialog box shows where you enter your Password and Click OK.

Connect to SharePoint Online Site using PowerShell

4. Now, we successfully connected PowerShell to our tenant.

Connect to SharePoint Online using PowerShell

5. Run the command below to test whether your SharePoint is connected.

Get-SPOSite

6. This will return all the site collections from your tenant like below:

How to Install and Connect SharePoint Online PowerShell

You can connect to the SharePoint Online site using Windows PowerShell ISE.

This PowerShell tutorial taught us about SharePoint Online Management Shell, how to download and install it, and connect to a SharePoint Online site using this shell.

We also learned how to connect to a SharePoint Online site using Windows PowerShell ISE.

I hope you got an overall idea about PowerShell.

Also, you may like some more PowerShell articles: