Powershell – Connect to Exchange Online

Connect to Exchange Online using powershell

I thought that I would share my script to connect to Exchange Online.

It is quite simple but is required to be able to work with Exchange Online together with Powershell.
This version also uses an URI that supports uploading user photos that are up to 100kb in size.

 

Solution

Copy this code and run it as a script in Powershell ISE.

$Credentials = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/?proxymethod=rps -Credential $Credentials -Authentication Basic -AllowRedirection
Import-PSSession $Session

When running this script you will be prompted for credentials to your Office 365 tenant.
Supply them and you will be connected and enabled to run your script in Exchange Online.

// Niclas

Leave a Reply

Your email address will not be published. Required fields are marked *