How To Connect Office 365 Exchange Online Services To PowerShell

In this write-up, we will see how to connect Office 365 Exchange Online Service to PowerShell for handling the O365 account services with PowerShell Commands. Just follow all the steps to know the process.

MS Office 365 is a very popular email client nowadays. Also, most people prefer Exchange Online for Business because it works with a GUI interface, however, people mostly use PowerShell commands for navigating their Office 365 Account. That’s why here I am going the discuss how to connect Office 365 Exchange Online Services to PowerShell. So, follow all the given steps for connecting the O365 services like Skype for business, security etc., with PowerShell.

Requirements for connecting O365 with Windows PowerShell

  • The Office 365 account should be a member of Global Admin Role.
  • Install Microsoft .NET Framework 4.5 and Windows Management Framework 3.0, 4.0 or the latest version.
  • In the end, download and install the modules of PowerShell for Office 365, SharePoint Online, and Skype on your PC.

    • Windows Azure Active Directory tool
    • Microsoft Online Services Sign-In Assistant for IT Professionals RTW
    • Skype for Business Online, Windows PowerShell Module

Connect Office 365 Admin account with PowerShell

Step 1

To control the Office 365 account, first, we need to connect Exchange Online Mailbox with Windows PowerShell. Just type the given command and press the Enter key on the keyboard. After that, log into the Office 365 Administrator account.

$credential = Get-Credential
 
How To Connect The Office 365 Exchange Online Services To The PowerShell 

Step 2

Now, verify the created credential object by putting the following command.

$credential

Step 3

Now, we need to save the credentials of the user and connect to the Exchange Online Server.

Connect-MsolService -Credential $credential

Step 4

Once you connect to Office 365, then verify and check how many domains are configured in the O365 tenant.

Get-MsolDomain

Step 5

You are successfully connected with Office 365 account, so now, we can navigate to Exchange Online with the help of PowerShell. You can also create the user account by the following PowerShell command.

New-MsolUser –UserPrincipalName [email protected] –DisplayName “Jhon Smith”

Step 6

Now, just create an Exchange Online remote session. For this, just type the given command.

$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection

After that, import the PS session or remote session.

Import-PSSession $exchangeSession –DisableNameChecking

Step 7

Check all the domains connected with the Exchange Online email addresses. So, put the below command to check the connecting Exchange Online domains.

Get-AcceptedDomain

 

Connect Security & Compliance Center to PowerShell

Step 1

First, run the following command to create a Security & Compliance Center remote session.

$ccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credential -Authentication Basic –AllowRedirection

Step 2

Now, create the import session.

Import-PSSession $ccSession -Prefix cc

Note
If nothing creates a problem, you will get the following figure.

 

Connect Skype for Business online with PowerShell

Step 1

First, we need to import the Skype module for Business Online.

Import-Module SkpyeOnlineConnector

Step 2

After that, create a remote session with one Office 365 Server.

$sfboSession = New-CsOnlineSession -Credential $credential

Step 3

Manage the Skype for Business Online by downloading the required script, cmdlets, and other items. 

Import-PSSession $sfboSession

Once you put the command, a process will run on the screen; you need to wait.

 

Conclusion

 
In this post, I explained how to connect the Office 365 Exchange Online Services to PowerShell. Here, I also discussed how we connect the Exchange Online, Skype for Business Online, and Security & Compliance Center with Windows PowerShell. If you have any doubts, leave your feedback in the comment box.


Similar Articles