Connect to SharePoint Online PowerShell 

Connect to SharePoint Online PowerShell 

If you are new to SharePoint or managing a small organization, you can use the SharePoint admin center. But the admin center is not suitable if you want to automate the process or manage a large organization. In that case, PowerShell is the only option. To manage SharePoint Online through PowerShell, install SharePoint Online Management Shell and connect to the SharePoint Online service. 

How to Install SharePoint Online Management Shell: 

To install the SharePoint Online PowerShell module, open the Windows PowerShell in administrator mode and install the module using the following cmdlet. 

Install-Module -Name Microsoft.Online.SharePoint.PowerShell 

If you don’t have administrator privilege on the system, run the cmdlet with –Scope param. For example, 

Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser 

Now, the SharePoint Online Management Shell module is installed and ready to use. 

To check the version of the module, run the following cmdlet. 

Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable 

 

How to Connect to SharePoint Online PowerShell: 

The ‘Connect-SPOService’ cmdlet is used to connect the SharePoint Online services. Before connecting to the SPO service, ensure that you have imported the SharePoint Online PowerShell module to avoid the following error: ‘Connect-SPOService is not recognized as a cmdlet’ 

To import SharePoint Online PowerShell module, execute the below cmdlet. 

Import-Module Microsoft.Online.SharePoint.Powershell 

To create SharePoint Online PowerShell session, run the following cmdlet. 

Connect-SPOService -Url htttps://<OrganizationName>-admin.sharepoint.com  

OrganizationName must be required to connect SPO service. For example, organization name is ‘Contoso’ for [email protected]  

You can also use the above format to connect to SharePoint Online PowerShell with MFA enabled accounts. 

Once you connect, execute the required SharePoint Online PowerShell cmdlets such as Get-SPOSiteGet-SPOGroup, etc. 

To close the SharePoint Online session, run the below cmdlet 

Disconnect-SPOService 

 

As you know, we can also manage SharePoint Online through the PnP PowerShell module. See you with the PnP PowerShell module cmdlets soon. Happy scripting! 

Connect to SharePoint Online PowerShell 

by Kathy time to read: 1 min
0