How To Connect To Office 365 Exchange Online Using PowerShell

How To Connect To Office 365 Exchange Online Using PowerShell

 

In this blog post, I’ll show you How To Connect To Office 365 Exchange Online Using PowerShell and manage Exchange Users, Mailboxes, Groups, Contacts and other Exchange Objects.

What many people don’t know that Office 365 Exchange Online Is actually an Exchange Server 2016 with a few restrictions that block Server level access.

Because many of the Exchange administrative tasks are not available from the Exchange Online portal we have to use Exchange Online PowerShell Module also known as EMS (Exchange Management Shell).

The code below Will connect to Exchange Online and Import all Exchange cmdlets to the session.

Please change, the first two variable to match your Office 365 admin account.

$powerUser = "[email protected]"

$powerPass = "PASSWORD"

$password = ConvertTo-SecureString $powerPass -AsPlainText -Force

$adminCredential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $powerUser,$password

$O365Cred = $adminCredential

Connect-MsolService –Credential $O365Cred

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

Import-PSSession $Session
How To Connect To Office 365 Exchange Online Using PowerShell
How To Connect To Office 365 Exchange Online Using PowerShell

To view, all the available cmdlets run the line below with name of the Imported session

Get-Command -Module tmp_5200myuq.1l4
How To Connect To Office 365 Exchange Online Using PowerShell
How To Connect To Office 365 Exchange Online Using PowerShell




Search blogs




Bitnami