Install Exchange Online PowerShell v2 module
This article describes how to install Exchange Online PowerShell v2 module so you can use it for connecting to all Exchange-related PowerShell environments in Office 365 or Microsoft 365:
- Connect to Exchange Online PowerShell or
- Connect to Exchange Online Protection PowerShell or
- Connect to Security & Compliance Center PowerShell.
The Exchange Online PowerShell V2 module (abbreviated as the EXO V2 module) uses modern authentication and works with multi-factor authentication (MFA) for connecting to Exchange Online PowerShell, Security & Compliance PowerShell, and standalone Exchange Online Protection (EOP) PowerShell.
After reading this install Exchange Online PowerShell v2 module article, you will have an understanding of:
- How the EXO V2 module works.
- How to install Exchange Online PowerShell v2 module and maintain the module.
- The optimized Exchange Online cmdlets that are available in the EXO V2 module.
The latest version of EXO V2 module and frequent use of the Connect-ExchangeOnline and Disconnect-ExchangeOnline cmdlets in a single PowerShell session or script might lead to a memory leak. The best way to avoid this issue is to use the CommandName parameter on the Connect-ExchangeOnline cmdlet to limit the cmdlets that are used in the session.
Exchange Online PowerShell v2 module download
You can download the Microsoft Exchange Online PowerShell v2 module (EXO V2 module) from the PowerShell gallery at:
https://www.powershellgallery.com/packages/ExchangeOnlineManagement/.
How the Exchange Online PowerShell v2 module (EXO V2 module) works
The EXO V2 module uses modern authentication for all cmdlets. You can’t use Basic authentication in the EXO V2 module; however, you still need to enable the Basic authentication setting in WinRM as explained later in this article.
The module contains a small set of exclusive Exchange Online PowerShell cmdlets that are optimized for bulk data retrieval scenarios (think: thousands and thousands of objects). When you first open the module, you’ll only see these exclusive cmdlets. After you connect to your Exchange Online organization, you’ll see all of the familiar cmdlets (Exchange Online PowerShell commands) that are available in Exchange Online PowerShell.
The Exchange Online cmdlets in the EXO V2 module are meant to replace their older, less efficient equivalents, but the equivalent cmdlets are still available (after you connect).
The improved Exchange Online PowerShell cmdlets that are only available in the EXO V2 module are listed in the following table:
Exchange Online PowerShell commands
The connection-related cmdlets that are available in the EXO V2 module are listed in the following table:
Older related cmdlet | EXO V2 module cmdlet |
---|---|
Connect-EXOPSSession or New-PSSession | Connect-ExchangeOnline |
Connect-IPPSSession | Connect-IPPSSession |
Remove-PSSession | Disconnect-ExchangeOnline |
Miscellaneous Exchange Online cmdlets that happen to be in the EXO V2 module are listed in the following table:
EXO V2 module cmdlet | Comments |
---|---|
Get-MyAnalyticsFeatureConfig | Available in v2.0.4 or later. |
Set-MyAnalyticsFeatureConfig | Available in v2.0.4 or later. |
Get-UserBriefingConfig | Replaced by Get-MyAnalyticsFeatureConfig. |
Set-UserBriefingConfig | Replaced by Set-MyAnalyticsFeatureConfig. |
Get-VivaInsightsSettings | Available in v2.0.5-Preview2 or later. |
Set-VivaInsightsSettings | Available in v2.0.5-Preview2 or later. |
Install Exchange Online PowerShell v2 module requirements
Exchange Online PowerShell v2 module requirements (also known as prerequisites for the EXO V2 module) are described below.
The settings described in this section are required in all versions of PowerShell on all operating systems.
Supported operating systems for the EXO V2 module
The latest version of the EXO V2 module is officially supported in PowerShell 7 on Windows, Linux, and Apple macOS.
Specifically, version 2.0.4 or later of the EXO V2 module is supported in PowerShell 7.0.3 or later.
Windows
All versions of the EXO V2 module are supported in Windows PowerShell 5.1.
PowerShell 7 on Windows requires version 2.0.4 or later of the EXO V2 module.
The EXO V2 module is supported in the following versions of Windows:
- Windows 10
- Windows 8.14
- Windows Server 2019
- Windows Server 2016
- Windows Server 2012 or Windows Server 2012 R24
- Windows 7 Service Pack 1 (SP1)1,2,3
- Windows Server 2008 R2 SP11,2,3
1 This version of Windows has reached its end of support, and is now supported only in Azure virtual machines.
2 This version of Windows doesn’t support version 2.0.4 or later of the EXO V2 module. Only version 2.0.3 or earlier is supported.
3 Windows PowerShell 5.1 on this version of Windows requires the Microsoft .NET Framework 4.5 or later and the Windows Management Framework 5.1. For more information, see Windows Management Framework 5.1.
4 PowerShell 7 on this version of Windows requires the Windows 10 Universal C Runtime (CRT).
How to check PowerShell version in Windows 10
- Open PowerShell Window (You don’t need to run it as administrator for this).
- Type: “Get-Host” and Press Enter to see your result.
- OR Type: “Get-Host | FL version” and Press Enter to see your result.
- OR Type: “$PSVersionTable” and Press Enter to see your result.
Get Execution Policy PowerShell (Set-Execution Policy to RemoteSigned)
To get the Execution Policy setting on your PC do the following:
- Open PowerShell Window (You don’t need to Run it as administrator for this).
- Type: “Get-ExecutionPolicy” and Press Enter to see your result.
PowerShell needs to be configured to run scripts, and by default, it isn’t. You’ll get the following error when you try to connect:
Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.
To ensure that all PowerShell scripts you download from the internet are signed by a trusted publisher, run the following command in an elevated PowerShell window (a PowerShell window you open by selecting Run as administrator):
PowerShell Script:
Set-ExecutionPolicy RemoteSigned
WinRM needs to allow Basic authentication (it’s enabled by default). We don’t send the username and password combination, but the Basic authentication header is required to send the session’s OAuth token, since the client-side WinRM implementation has no support for OAuth.
Note: You must temporarily enable WinRM to run the following commands. You can enable WinRM by running the command:
(Open Command Prompt (Run as Administrator)
- Type “cmd” in the search field
- Open best match “Command Prompt App” (Run as Administrator)
- type the command below in the command prompt window.
winrm quickconfig
To verify that Basic authentication is enabled for WinRM, run this command in a Command Prompt (not in PowerShell):
Command Prompt (DOS script)
winrm get winrm/config/client/auth
If you don’t see the value Basic = true, you need to run this command in a Command Prompt (not in PowerShell) to enable Basic authentication for WinRM:
Command Prompt (DOS script)
winrm set winrm/config/client/auth @{Basic=”true”}
Note: If you’d rather run the command in PowerShell, enclose this part of the command in quotation marks: ‘@{Basic=”true”}’.
If Basic authentication for WinRM is disabled, you’ll get this error when you try to connect:
The WinRM client cannot process the request. Basic authentication is currently disabled in the client configuration. Change the client configuration and try the request again.
Install Exchange Online PowerShell v2 module (EXO V2 module)
To install the EXO V2 module for the first time, complete the following steps:
Install or update the PowerShellGet
Step 1: Install or update the PowerShellGet module as described in Installing PowerShellGet.
Close and re-open the Windows PowerShell window
Step 2: Close and re-open the Windows PowerShell window.
Install the EXO V2 module
Step 3: Now you can use the Install-Module cmdlet to install the EXO V2 module from the PowerShell Gallery. Typically, you’ll want the latest public version of the module, but you can also install a Preview version if one is available.
To install the latest public version of the module, run one of the following commands:
These commands must be run in an elevated PowerShell window (a PowerShell window you open by selecting Run as administrator):
Install the EXO V2 module for All users:
PowerShell
Install-Module -Name ExchangeOnlineManagement
Install the EXO V2 module Only for the current user account:
PowerShell
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
To install a Preview version of the module, replace with the necessary value, and run one of the following commands:
In an elevated PowerShell window (all users):
PowerShell
Install-Module -Name ExchangeOnlineManagement -RequiredVersion -AllowPrerelease
Only for the current user account:
PowerShell
Install-Module -Name ExchangeOnlineManagement -RequiredVersion -AllowPrerelease -Scope CurrentUser
When you’re finished, enter Y to accept the license agreement.
For detailed syntax and parameter information, see Install-Module.
Update the EXO V2 module
If the module is already installed on your computer, you can run the following commands to see the version that’s currently installed and update it to the latest version from the PowerShell Gallery:
To see the version of the module that’s currently installed, run the following commands:
PowerShell
Import-Module ExchangeOnlineManagement; Get-Module ExchangeOnlineManagement
You can use the Update-Module cmdlet to update the EXO V2 module from the PowerShell Gallery. Typically, you’ll want the latest public version of the module, but you can also upgrade to a Preview version if one is available.
To upgrade to the latest public version of the module, run one of the following commands based on how you originally installed the module (in an elevated PowerShell window vs. Scope CurrentUser):
In an elevated PowerShell window (all users):
PowerShell
Update-Module -Name ExchangeOnlineManagement
Only for the current user account:
PowerShell
Update-Module -Name ExchangeOnlineManagement -Scope CurrentUser
To upgrade to a Preview version of the module, replace with the necessary value, and run one of the following commands based on how you originally installed the module (in an elevated PowerShell window vs. Scope CurrentUser):
In an elevated PowerShell window (all users):
PowerShell
Update-Module -Name ExchangeOnlineManagement -RequiredVersion -AllowPrerelease
Only for the current user account:
PowerShell
Update-Module -Name ExchangeOnlineManagement -RequiredVersion -AllowPrerelease -Scope CurrentUser
When you’re finished, enter Y to accept the license agreement.
To confirm that the update was successful, run the following commands to check the version information of the module that’s installed:
PowerShell
Import-Module ExchangeOnlineManagement; Get-Module ExchangeOnlineManagement
For detailed syntax and parameter information, see Update-Module.
Troubleshoot installing the EXO V2 module
If you receive the following error:
The specified module ‘ExchangeOnlineManagement’ with PowerShellGetFormatVersion ” is not supported by the current version of PowerShellGet. Get the latest version of the PowerShellGet module to install this module, ‘ExchangeOnlineManagement’.
Update your installation of the PowerShellGet module to the latest version as described in Installing PowerShellGet. Be sure to close and re-open the PowerShell window before you attempt to update the ExchangeOnlineManagement module again.
As of April 2020, the PowerShell Gallery only supports connections using TLS 1.2 or later. For more information, see PowerShell Gallery TLS Support.
To check your current settings in the Microsoft .NET Framework, run the following command in Windows PowerShell:
PowerShell
[Net.ServicePointManager]::SecurityProtocol
As described in the PowerShell Gallery TLS Support article, to temporarily change the security protocol to TLS 1.2 to install the PowerShellGet or ExchangeOnlineManagement modules, run the following command in Windows PowerShell before you install the module:
PowerShell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
To permanently enable strong cryptography in the Microsoft .NET Framework version 4.x or later, run one of the following commands based on your Windows architecture:
x64:
PowerShell
Set-ItemProperty -Path ‘HKLM:\SOFTWARE\Wow6432Node\Microsoft.NETFramework\v4.0.30319’ -Name ‘SchUseStrongCrypto’ -Type DWord -Value ‘1’
x86:
PowerShell
Set-ItemProperty -Path ‘HKLM:\SOFTWARE\Microsoft.NETFramework\v4.0.30319’ -Name ‘SchUseStrongCrypto’ -Type DWord -Value ‘1’
For more information, see SchUseStrongCrypto.
Uninstall the EXO V2 module
To uninstall the module, run one of the following commands based on how you originally installed the module (in an elevated PowerShell window vs. Scope CurrentUser):
In an elevated PowerShell window (all users):
PowerShell
Uninstall-Module -Name ExchangeOnlineManagement
Only for the current user account:
PowerShell
Uninstall-Module -Name ExchangeOnlineManagement
For detailed syntax and parameter information, see Uninstall-Module.
Properties and property sets in the EXO V2 module
Traditional Exchange Online cmdlets return all possible object properties in their output, including many properties that are often blank or aren’t interesting in many scenarios. This behavior causes degraded performance (more server computation and added network load). You rarely (if ever) need the full complement of properties in the cmdlet output.
The Get-EXO* cmdlets in the module have categorized output properties. Instead of giving all properties equal importance and returning them in all scenarios, we’ve categorized specific related properties into property sets. Simply put, these property sets are buckets of two or more related properties on the cmdlet.
In the biggest and most used Get-EXO* cmdlets:
Property sets are controlled by the following parameters:
- PropertySets: This parameter accepts one or more available property set names separated by commas. The available property sets are described in Property sets in Exchange Online PowerShell V2 cmdlets.
- Properties: This parameter accepts one or more property names separated by commas.
You can use the PropertySets and Properties parameters together in the same command.
We’ve also included a Minimum property set that includes a bare minimum set of required properties for the cmdlet output (for example, identity properties). The properties in the Minimum property sets are also described in Property sets in Exchange Online PowerShell V2 cmdlets.
- If you don’t use the PropertySets or Properties parameters, you automatically get the properties in the Minimum property set.
- If you use the PropertySets or Properties parameters, you get the specified properties and the properties in the Minimum property set.
Either way, the cmdlet output will contain far fewer properties, and the time it takes to return those results will be much faster.
For example, after you connect to Exchange Online PowerShell, the following example returns only the properties in the Minimum property set for the first ten mailboxes.
PowerShell
Get-EXOMailbox -ResultSize 10
In contrast, the output of the same Get-Mailbox command would return at least 230 properties for each of the first ten mailboxes.
Note
Although the PropertySets parameter accepts the value All, we highly discourage using this value to retrieve all properties, because it slows down the command and reduces reliability. Always use the PropertySets and Properties parameters to retrieve the minimum number of properties that are required for your scenario.
For more information about filtering in the EXO V2 module, see Filters in the Exchange Online V2 module.
Release notes
Unless otherwise noted, the current release of the EXO V2 module contains all features of previous releases.
Current release: Version 2.0.5
New Get-OwnerlessGroupPolicy and Set-OwnerlessGroupPolicy cmdlet to manage ownerless Microsoft 365 groups.
Note
Although the cmdlets are available in the module, the feature is only available to members of a Private Preview.
New Get-VivaInsightsSettings and Set-VivaInsightsSettings cmdlets to control user access to Headspace features in Viva Insights.
Previous releases
Version 2.0.4
PowerShell 7 is officially supported in Windows, Linux, and Apple macOS as described in the Prerequisites for the EXO V2 module section in this article.
The EXO V2 module in PowerShell 7 supports browser-based single sign-on (SSO) and other sign in methods. For more information, see PowerShell 7 log in experiences.
The Get-UserAnalyticsConfig and Set-UserAnalyticsConfig cmdlets have been replaced by the Get-MyAnalyticsConfig and Set-MyAnalyticsConfig.Additionally, you can configure access at feature level. For more information, see Configure MyAnalytics.
Real-time policy and security enforcement in all user-based authentication. Continuous Access Evaluation (CAE) has been enabled in EXO V2 Module. Read more about CAE here.
The LastUserActionTime and LastInteractionTime properties are now available in the output of the Get-EXOMailboxStatistics cmdlet.
The interactive sign-in process now uses a more secure method to fetch access tokens using safe reply URLs.
Related Articles: Microsoft 365 Business Basic vs Standard
Further Reading: about the Exchange Online PowerShell v2 module Microsoft docs