Categories
Exchange Microsoft Office 365 PowerShell Windows

How to connect to Exchange Online with PowerShell

I realized that my previous post might have been confusing about how to connect to Exchange Online. So I wanted to do a post on how you can connect to Exchange Online Using PowerShell.

First things first, because some of the scripts that you will need to run are not native to your machine, you will need to run this command, probably as an administrator before you can try to connect.

Set-ExecutionPolicy RemoteSigned

Next you will need to set your login credentials. This account needs to have administrative privileges in Exchange Online for it to Connect:

$UserCredential = Get-Credential

This will bring up a Office 365 login prompt. Enter your username, then your password and when it is done the screen will close and you will be back in PowerShell
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Lastly you will need to run this command

Import-PSSession $Session -DisableNameChecking

Which will enable several commands that are now available to you.
I hope that this guide helps you, I know that I always forget how to do this so doing a Blog post should help. 
Please feel free to share with your friends if you think it will help them. 

Leave a Reply