Using PowerShell with Office 365 – Exchange

Jun - 20 2022 | By

There are a variety of commands in PowerShell that you can use to make changes for individuals and for your entire organization

Below are the commands to issue in PowerShell to connect to your account, the user that signs in should be a Administrator for your Office 365 organization.  This will focus on Exchange features of Office 365.

You will need the EXO V2 modules for PowerShell, below are the steps to install, PowerShell must be started as a Administrator.

Make sure PowerShell has RemoteSigned packages from a trusted publisher allowed issue the following command.

Set-ExecutionPolicy RemoteSigned

Install the EXO V2 module:

Install-Module -Name ExchangeOnlineManagement

For more about the installation of the EXO V2 module see –  for information on the package see –

The Import-Module will import the commands that work with Exchange in PowerShell. Use this command to connect – change to your email account with administrator rights. This command will bring up a Microsoft Modern Authentication prompt to sign into your account.  This sign in will focus on Exchange email capabilities of Microsoft 365.

Import-Module ExchangeOnlineManagement

Connect-ExchangeOnline -UserPrincipalName -ShowProgress $true

To disconnect your PowerShell session from Office 365 use this command to sign you out.


Microsoft Documentation on Microsoft 365 with PowerShell