The Exchange Online PowerShell module enables you to manage your Exchange Online environment from the command line. Using the command line is often a simpler, faster and a more convenient way of administering your Microsoft 365 and Exchange environment.Â
As well as being a faster approach to administering Exchange Online. Using PowerShell will also help you automate significant tasks when needing to make complex or bulk changes throughout your organisation.
In this post I am going to cover how you can install Exchange Online PowerShell module, keep it maintained/updated and connect to your environment.Â
Check which version of Exchange Online Management you have installed
Use the below script to check which version of the Exchange Online Management module you are running.
$EXO = get-installedmodule | Where-Object {$_.Name -Eq "ExchangeOnlineManagement"}
If ($Exo -eq $null) {
write-host "Exchange Online Management is not installed"
} Else {
Write-host "Exchange Online Management version" $EXO.Version "is installed"
}
How to Install the Exchange Online PowerShell module
Before you begin, you will need to install the Exchange Online PowerShell module. This will enable you to use the necessary cmdlets in your PowerShell sessions. You should always ensure your are installing the latest version of the Exchange Online PowerShell module so you have all the latest commands available and get the best experience.
1. Open PowerShell as an administrator.
2. Ensure you have enabled the running of scripts in PowerShell on your system. The following command will allow the running of scripts for your current user context.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
#or to enable the running of scripts in PowerShell for all users.
Set-ExecutionPolicy unrestricted
3. Use the install-module command to install the Exchange Online management module.
install-module exchangeonlinemanagement -scope CurrentUser
4. Use the get-installedmodule cmdlet to verify the new module is installed.
get-installedmodule
In the result you should see the name of the Exchange Online Module and the current version.
Upgrade the ExchangeOnline PowerShell module to the latest version
As mentioned above, you should ensure you are on the latest build of the Exchange Online PowerShell module for the best experience and to provide you the most functionality.
1. Start by running the get-installedmodule cmdlet to verify which version of the module you are currently running. Below you can see I am running version 2.0.5.
2. Now check the PowerShell gallery to review which is the latest version of the Exchange Online Management module: https://www.powershellgallery.com/packages/ExchangeOnlineManagement/3.0.0.Â
As you can see below, the latest version is now 3.0.0.
3. Use the Update-Module ExchangeOnlineManagement cmdlet to update the module to the latest version.
Update-Module ExchangeOnlineManagement
4. You can check this successfully updated the ExchangeOnlineManagement module by running get-installedmodule again. You can now see that the module is up to date:
How to connect to Exchange Online PowerShell
Now you have the necessary cmdlets installed to you system, you are ready to connect to Exchange Online PowerShell. When you connect to your tenant, you will do so using Modern Authentication. To make the most out of this experience ensure you have enabled Multi-Factor authentication on your Microsoft 365 account.Â
Previously, you may have used basic authentication where the username and password was written in plain-text. This is no longer considered safe or secure.
- Open PowerShell.
2. Run the import-module command to load the Exchange Online PowerShell module into your session.
import-module ExchangeOnlineManagement
3. Connect to Exchange online with the following command “Connect-ExchangeOnline“.
Connect-ExchangeOnline
4. The following window will open to allow you to sign in with your Microsoft 365 account. If you are looking to administer your environment, this will be your Global Admin or Exchange Admin login.
Hello Daniel, your blog is becoming my go to source when I need something related to PowerShell for Microsoft 365, Exchange online, Entra or some other MS cloud product. I see that some tasks can be managed with “ExchangeOnlineManagement” module and other with PowerShell for graph modules. Do you thing “ExchangeOnlineManagement” will be gone like the MS online and AZure AD modules?
Hi Martin,
I do envisage that it might happen, so worth skilling up on Microsoft Graph well in advance 😉 It won’t be anytime soon through as MS are still putting development efforts in Exchange Online Management.