Exchange Online PowerShell V3 module (EXO V3 module) was made generally available (GA) in September 2022. The first version of V3 module was version 3.0.0, this version onwards all cmdlets in the module will use REST API Connections.
Exchange Online PowerShell V2 module (EXO V2 module) which was based on RPS (Remote PowerShell) is now a legacy method for connecting to exchange online. If you are still using EXO V2 module, you can switch to new and improved EXO V3 PowerShell module.
If you are using New-PSSession
for connecting to Exchange or Exchange online PowerShell v1 and v2 PowerShell modules, then you are using Remote PowerShell (RPS). Recommended method for connecting to Exchange online is by using Connect-ExchangeOnline
which uses modern authentication methods.
Contents
Important Points above EXO V3 Module
- Built-in Modern authentication support.
- All EXO V3 cmdlets are based on REST API, which perform better and are more reliable.
- 9 Exclusive
Get-EXO*
cmdlets optimized for bulk data retrieval, includingGet-EXOMailbox
cmdlet. - Connect using
Connect-ExchangeOnline
command for MFA and non-MFA accounts. - An experimental
UseCustomRouting
switch available for certain commands likeGet-MailboxStatistics
which connects directly to the mailbox server for improving performance. - Use of
Get-ConnectionInformation
for getting information about REST API connection Information.
Install Exchange Online PowerShell V3 Module
Let’s check the steps to Install Exchange Online PowerShell V3 module (EXO V3 Module):
1. Set PowerShell Execution Policy to RemoteSigned
To install the EXO V3 module, you’ll first need to configure PowerShell to allow script execution. By default, script execution is disabled on Windows devices, so we’ll need to change the execution policy to RemoteSigned.
Setting the execution policy to RemoteSigned ensures that any scripts you download from the internet must be signed by a trusted publisher to run safely on your system. Open PowerShell console as administrator and execute below command.
Set-ExecutionPolicy RemoteSigned
2. Install PowerShellGet and PackageManagement
Rest API connections on Windows devices will require PowerShellGet and PackageManagement modules. Ensure that those are installed on your device. To check if the modules are installed, open PowerShell console as administrator and execute below command.
List of Available PowerShellGet, PackageManagement versions
Get-Module PowerShellGet, PackageManagement -ListAvailable
To install or upgrade PowershellGet and PackageManagement modules on your device, run below command and then run the previous Get-module command again to check if you see the latest versions in the list. If you find multiple versions and want to get rid of older versions, you can refer to the post: Remove Old PowerShellGet and PackageManagement Modules.
Install and Upgrade PowerShellGet and PackageManagement
Install-Module PowerShellGet -Force -AllowClobber
3. Install Exchange Online PowerShell V3 Module (EXO V3)
If you want to Install Exchange Online PowerShell V3 module for all users of the device, then you need to open PowerShell console as administrator and execute below command:
Install EXO V3 for All Users
Install-Module -Name ExchangeOnlineManagement
To Install EXO V3 Latest Preview version
Install-Module -Name ExchangeOnlineManagement -AllowPrerelease
If you want to Install Exchange Online PowerShell V3 module only for the current user account, then execute below command. You do not have to open PowerShell console as an administrator this time.
Install EXO V3 for Current User
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
To Install EXO V3 Latest Preview version
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -AllowPrerelease
Get Installed Exchange Online PowerShell Module Version
To check and confirm the Exchange Online PowerShell module installation and its version information, execute below command on PowerShell console.
Get Exchange Online PowerShell Module Information
Get-InstalledModule ExchangeOnlineManagement | Format-List Name,Version,InstalledLocation, InstalledDate
Connect to Exchange Online PowerShell
You can execute the following commands on PowerShell console to connect to Exchange Online.
Import Exchange Online PowerShell V3 module
Import-Module ExchangeOnlineManagement
Connect to Exchange Online using V3 module [with MFA] [Recommended]
Connect-ExchangeOnline -UserPrincipalName <Admin UPN>
Example:
Connect-ExchangeOnline -UserPrincipalName [email protected]
Connect to Exchange Online using V3 module [Without MFA]
$Credential = Get-Credential
Connect-ExchangeOnline -Credential $credential
Connect to EXO PowerShell using V3 module [Without MFA] [Only for PowerShell 7]
Connect-ExchangeOnline -UserPrincipalName <Admin UPN> -InlineCredential
Example:
Connect-ExchangeOnline -UserPrincipalName [email protected] -InlineCredential
Connect to EXO PowerShell using V3 module using another device [With or Without MFA] [Only for PowerShell 7]
Connect-ExchangeOnline -Device
New Cmdlets in Exchange Online PowerShell V3 Module
New Cmdlet (V3) | Corresponding Old Cmdlet |
---|---|
Connect-ExchangeOnline | Connect-EXOPSSession |
Disconnect-ExchangeOnline | Remove-PSSession |
Get-ConnectionInformation | Get-PSSession |
Get-EXORecipient | Get-Recipient |
Get-EXOMailbox | Get-Mailbox |
Get-EXOMailboxFolderStatistics | Get-MailboxFolderStatistics |
Get-EXOMailboxStatistics | Get-MailboxStatistics |
Get-EXOAddressBookPolicy | Get-AddressBookPolicy |
Get-EXOCASMailbox | Get-CASMailbox |
Get-EXOMobileDeviceStatistics | Get-MobileDeviceStatistics |
Get-EXOMailboxPermission | Get-MailboxPermission |
Get-EXOAddressList | Get-AddressList |
Get-EXOMailboxPlan | Get-MailboxPlan |
Get-EXOMailUser | Get-MailUser |
Get-EXOMailContact | Get-MailContact |
Get-EXOGroup | Get-Group |
Get-EXORecipientPermission | Get-RecipientPermission |
Get-EXOOrganizationConfig | Get-OrganizationConfig |
Set-EXOMailbox | Set-Mailbox |
Set-EXORecipient | Set-Recipient |
Set-EXOMailboxPermission | Set-MailboxPermission |
Set-EXOCASMailbox | Set-CASMailbox |
New-EXOMailbox | New-Mailbox |
New-EXOAddressBookPolicy | New-AddressBookPolicy |
New-EXORecipient | New-Recipient |
Remove-EXOMailbox | Remove-Mailbox |
Remove-EXOMailboxPermission | Remove-MailboxPermission |
Remove-EXORecipient | Remove-Recipient |
Disconnect the Session
It’s always a best practice to disconnect the session once your work is finished. If you do not disconnect the session, then you could reach the session limit, and you may have to wait for existing sessions to expire before you could open a new session. To disconnect from Exchange online PowerShell session, use below command:
Disconnect from Exchange Online
Disconnect-ExchangeOnline -Confirm:$false