PowerShell connection to exchange online

  • by

First of all you need to open a powershell window.

Enter user credentials for accessing Office 365

$UserCredential = Get-Credential

Open the connection

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

Get the remote commands

Import-PSSession $Session -DisableNameChecking

Disconnect afterwards

Remove-PSSession $Session

Source

https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps