Office 365 Sharepoint Online Powershell

Jennifer Agustin
JJ365
Published in
3 min readSep 12, 2019
Connecting to SharePoint Online
Photo by Headway on Unsplash

Connect a SharePoint Online global administrator to a SharePoint Online connection (SharePoint Online Administration Center)

Today, we’ll be connecting to the SharePoint Online Administration Center as a global administrator. Before doing that, however, we should perform a prerequisite first.

Note: You only need to set execution policy once. If you already performed this before, you may skip this section.

Set Execution Policy

Step 1: Open Windows Powershell and run it as an administrator

Step 2: Require all Powershell scripts downloaded from the internet are signed by a trusted publisher

Set-ExecutionPolicy RemoteSigned

If you haven’t done this step, you’ll get the following error:

“Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.”

Connect to Office 365 SharePoint Online

Step 1: Download the Sharepoint Online Management Shell(SOMS) below:

https://www.microsoft.com/en-us/download/details.aspx?id=35588

To check if you already installed it, you can run the Windows Powershell commands below:

Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
Get-Module Command — Connecting to SharePoint Online
Get-Module Command

If your operating system is using Powershell 5 or newer, you can install the SOMS by running this command:

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

Step 2: Connect to Sharepoint Online Service by using the commands below:

Using Variables

$adminUPN = ”jj@jj365.com”
  • The admin UPN should be your Office365 admin account.
$orgName = ”JJ365”
  • The organization name should be your initial domain (e.g., jj365.onmicrosoft.com) and not your vanity domain.
$userCredential = Get-Credential -UserName $adminUPN -Message “globaladminpassword”Connect-SPOService -Url https://$orgName-admin.sharepoint.com-Credential $userCredential

Another Way of Connecting to SharePoint Online

Alternatively, you can connect to SharePoint Online Service just by doing these steps.

Step 1: Run the following command.

Connect-SPOService
  • It would then ask for your Sharepoint URL, something like the one below.
https://jj365-admin.sharepoint.com
Connect-SPOService Command — Connecting to SharePoint Online
Connect-SPOService Command

Note: Do not forget the -admin because you would encounter this error below:

Connection Error — Connecting to SharePoint Online
Connection error

Step 2: After entering the URL, it would ask for your Office365 admin credentials.

Office365 Admin Credentials — Connecting to SharePoint Online
Office365 Admin Credentials

Note: Unlike in Exchange Online, it does not have a session, so you don’t have to remove any sessions once you’re finished.

Connect to Sharepoint Online Service using MFA

Unlike Exchange Online, you don’t have to download any module to connect to Sharepoint Online Service using MFA. You have to do the normal process, and on the credential prompt, you have to enter the code for verification.

Step 1: Run the following command

Connect-SPOService -url https://jj365-admin.sharepoint.com

Step 2: Enter your Office365 Admin credentials, and after entering your password, it would go to the verification page where you need to enter the code sent to your mobile device.

There you go! You should be able to connect to your SharePoint Online as a global administrator and start doing your stuff.

I hope this helped you in some way. Until the next one!

Thank you :)

--

--

Jennifer Agustin
JJ365
Editor for

MCSE Level 2 Cloud Support Engineer for Office365