This PowerShell SharePoint tutorial, we will discuss how to connect to a SharePoint Online site using PowerShell. We will see, how to connect to SharePoint Online Office 365 site using SharePoint Online Management Shell.
SharePoint 2016 Tutorial Contents
To work with SharePoint Online using Online management shell, we need to download and install “SharePoint Online management shell” in each system from which you want to connect to your SharePoint Online.
We can use SharePoint Online Management Shell to manage SharePoint Online users, sites, and site collections, lists, libraries, etc. SharePoint Online Management Shell commands differs from Office 365 Commands.
Office 365 commands manage Office 365-level tasks such as users, licenses, organization information, and services.
Regarding permission, to use SharePoint Online PowerShell commands, you must be a SharePoint Online global administrator.
To use the SharePoint Online management shell we need to download and install SharePoint Online Management Shell.
First, download SharePoint Online Management Shell from this MSDN URL.
Click on the download button and then choose the particular version (64 bit or 32 bit).
Then click on the installer to install the SharePoint Online management shell.
Once it is installed successfully, it will show the completion wizard.
After this, if you will search for “SharePoint Online Management Shell”, we can see the management shell available.
Now you can open the SharePoint Online management shell and run the below command to connect to SharePoint Online.
Connect-SPOService -Url https://<tenantname>-admin.sharepoint.com -credential [email protected]<tenantname>.onmicrosoft.com
Once you run the command it will ask for a password and then it will connect to SharePoint online site. Remember the user must be a SharePoint Online global administrator to use SharePoint Online PowerShell commands.
We can also connect to SharePoint Online Office 365 sites using Windows PowerShell ISE. For that, we have to import “Microsoft.Online.SharePoint.PowerShell” like below:
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
And then we can use the Connect-SPOService command like below:
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking Connect-SPOService -Url https://<tenantname>-admin.sharepoint.com -credential [email protected]<tenantname>.onmicrosoft.com
Once you run the above command, it will ask for the password and once you enter the password and click on OK, it will connect to the site.
To test it you can run the below command.
This will return all the site collections from your Office 365 tenant like below:
Current site is not a tenant administration site
If you got an error like Connect-SPOService : Current site is not a tenant administration site.
Then check [Solved] Connect-SPOService : Current site is not a tenant administration site
You may like following PowerShell SharePoint Online tutorials:
- Getting Started with PnP PowerShell – SharePoint 2013/2016/SharePoint Online
- Bulk SharePoint Online Site Collection Creation using PowerShell
- The remote server returned an error (401) Unauthorized SharePoint online management shell error
- Create Subsite using PowerShell in SharePoint Online
- Powershell with recursive looping in SharePoint Online
- Retrieve SharePoint Online List Templates using PowerShell
- Create List or Document Library using PowerShell in SharePoint Online
- Add items from CSV file to SharePoint Online List using PowerShell in CSOM
- Get Subsites of a Site Collection in SharePoint Online using PowerShell
- Create Site Collection in SharePoint Online using PowerShell
Hope this SharePoint tutorial explains, how to connect to the SharePoint Online site from PowerShell or from SharePoint Online management shell.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.