Connect to Exchange Online

On your local computer, open Windows PowerShell and run the following command –

$UserCredential = Get-Credential

In the Windows PowerShell Credential Request dialog box, type your Office 365 user name and password, and then click OK.

Run the following command –

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection

Then run the command –

Import-PSSession $Session

You need to connect to the Microsoft Online Service for a number of operations. To do so run the following command using the credentials you input as above –

Connect-MsolService -Credential $UserCredential

Once you have finished with the session run the command –

Remove-PSSession $Session