Access Exchange Online via PowerShell

After recently deploying a hybrid configuration for Office 365, many email settings that were easily configurable within Office 365 portal could not be changed as these settings were being managed by on-premise Active Directory servers. To get past this restriction, the next best option is to access the Exchange Online via PowerShell.

Note: PowerShell 3.0 is required. For Windows Server 2012 or Windows Server 2012 R2, PowerShell does not need to be updated by default as PowerShell 3.0 is part of the operating system.

Access Exchange Online with PowerShell

First, tell PowerShell which credentials will be needed to connect to Exchange Online. For the prompt that will appear, you will need to connect using an Exchange Online administrator. If you are in an O365 Hybrid configuration, this could be a user that is on your domain or could be a stand-alone user with administrative privileges in Exchange Online.

Note: When opening up PowerShell, you will want to use the Run as Administrator command.

$LiveCred = Get-Credential

Step 1

Next, we will connect to Exchange Online.

$Session = New-PSSession – ConfigureationName Microsoft.Exchange –ConnectionUrlhttps://ps.outlook.com/powershell/ -Credential $LiveCred –Authentication Basic -AllowRedirection

Step 2

By default, the execution policy will set to restricted. Changing this to allow commands to be ran from the PowerShell window requires us to allow commands to be remote-signed.

Set-ExecutionPolicy RemoteSigned

Step 3

Typically, after I am finished utilizing PowerShell, I will set the execution policy back to a restricted policy as these settings do not revert on closing PowerShell.

Set-ExecutionPolicy Restricted

Step 4