skip to Main Content

Install Exchange Online PowerShell V2

How to install Exchange Online PowerShell V2 and connect to Exchange Online? A migration is planned for next week. The mailboxes are going to be migrated from on-premises to Exchange Online. We are going to install the new EXO PowerShell V2 module and use it for migrating. I recommend migrating mailboxes with PowerShell instead of the Exchange Admin Center. In this article, you will learn how to install Exchange Online PowerShell V2 module.

Exchange Online PowerShell V2 module

The Exchange Online PowerShell V2 module (abbreviated as the EXO V2 module) enables admins to connect to their Exchange Online environment in Microsoft 365 to retrieve data, create new objects, update existing objects, remove objects as well as configure Exchange Online and its features.

The Exchange Online PowerShell V2 module is currently in General Availability (GA). It is stable and ready for use in production environments. This started from version 1.0.1. If you have an older version running, update the EXO V2 module.

Some key points about EXO V2 module:

  • Download from PowerShell gallery
  • Run the module from Windows PowerShell and Windows PowerShell ISE
  • Single cmdlet Connect-ExchangeOnline supports both MFA and non-MFA accounts
  • EXO V2 cmdlets are REST API-based which are much faster and more reliable
  • EXO V2 uses Modern Authentication
  • Older cmdlets are backward compatible

Keep up to date and have a look at the Microsoft website for the release notes.

Install Exchange Online PowerShell V2 module

Before we can install Exchange Online PowerShell V2 module, we need to set up the system.

Set Windows PowerShell Execution Policy

By default, we can’t install scripts. To require all PowerShell scripts that you download from the internet are signed by a trusted publisher, run PowerShell as administrator, and run the cmdlet. Press Y and press Enter.

PS C:\> Set-ExecutionPolicy RemoteSigned

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y

Important: Close and re-open the elevated Windows PowerShell window to have the changes apply.

Install PowerShellGet module

Run PowerShell as administrator. Run the command Install-Module PowershellGet -Force. When asked to install NuGet provider, press Y and follow with Enter.

PS C:\> Install-Module PowershellGet -Force

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\administrator.EXOIP\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion -Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y

If you are getting an error that it’s unable to install, read the article Unable to install NuGet provider for PowerShell.

Install Exchange Online Management module

Install the Exchange Online Management module. Press Y and Enter.

PS C:\> Install-Module -Name ExchangeOnlineManagement

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y

Connect to Exchange Online PowerShell V2

Connect to Exchange Online PowerShell using the EXO V2 module with or without MFA.

We recommend to enable MFA (Multi-Factor Authentication) on the accounts.

Connect with your admin account to Exchange Online. Run the Connect-ExchangeOnline cmdlet.

PS C:\> Connect-ExchangeOnline -UserPrincipalName

In the sign-in window that opens, enter your password, and then click Sign in.

Install Exchange Online PowerShell V2 sign in

If MFA is enabled, a verification code is generated and delivered based on the verification response option that’s configured for your account. For example, a text message or the Azure Authenticator app on your mobile phone.

Install Exchange Online PowerShell V2 MFA

After the verification succeeds, you will get back to the PowerShell window, and the new cmdlets will show in a banner.

We have released new management cmdlets which are faster and more reliable.

|    Old Cmdlets                    |    New/Reliable/Faster Cmdlets       |
|    Get-CASMailbox                 |    Get-EXOCASMailbox                 |
|    Get-Mailbox                    |    Get-EXOMailbox                    |
|    Get-MailboxFolderPermission    |    Get-EXOMailboxFolderPermission    |
|    Get-MailboxFolderStatistics    |    Get-EXOMailboxFolderStatistics    |
|    Get-MailboxPermission          |    Get-EXOMailboxPermission          |
|    Get-MailboxStatistics          |    Get-EXOMailboxStatistics          |
|    Get-MobileDeviceStatistics     |    Get-EXOMobileDeviceStatistics     |
|    Get-Recipient                  |    Get-EXORecipient                  |
|    Get-RecipientPermission        |    Get-EXORecipientPermission        |

To get additional information, run: Get-Help Connect-ExchangeOnline
Please send your feedback and suggestions to

PS C:\>

If you don’t want to show the screen output when connecting to Exchange Online, make use of the -ShowBanner switch. This will hide the banner as seen above.

PS C:\> Connect-ExchangeOnline -UserPrincipalName -ShowBanner:$false

Now we are connected to Exchange Online PowerShell and ready to type in the new cmdlets.

Exchange Online PowerShell V2 new cmdlets

See the list of new and old cmdlets.

New cmdlet in the EXO V2 moduleOlder related cmdlet
Get-EXOMailbox Get-Mailbox
Get-EXORecipient Get-Recipient
Get-EXOCASMailbox Get-CASMailbox
Get-EXOMailboxPermission Get-MailboxPermission
Get-EXORecipientPermission Get-RecipientPermission
Get-EXOMailboxStatistics Get-MailboxStatistics
Get-EXOMailboxFolderStatistics Get-MailboxFolderStatistics
Get-EXOMobileDeviceStatistics Get-MobileDeviceStatistics
Connect-ExchangeOnline Connect-EXOPSSession
Connect-IPPSSession Connect-IPPSSession
Disconnect-ExchangeOnline Remove-PSSession

Disconnect Exchange Online

Disconnect the remote PowerShell session when you’re finished. If you close the Exchange Online PowerShell Module window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you’ll need to wait for the sessions to expire.

This cmdlet is the V2 equivalent of Get-PSSession | Remove-PSSession. In addition to cleaning up session object and local files, it also removes the access token from cache, which is used for authenticating against V2 cmdlets.

PS C:\> Disconnect-ExchangeOnline

Running this cmdlet clears all active sessions created using Connect-ExchangeOnline or Connect-IPPSSession.
Press(Y/y/A/a) if you want to continue.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
Removed the PSSesion ExchangeOnlineInternalSession_2 connected to
Disconnected successfully !

That’s it!

Read more: Get mailbox size greater than in Office 365 »


You learned how to install Exchange Online PowerShell V2. Connect to Exchange Online PowerShell using the Exchange Online PowerShell V2 module with or without MFA. After connecting to Exchange Online, you can make use of the new cmdlets.

Did you enjoy this article? You may also like Get mailbox permissions with PowerShell. Follow us on Twitter and LinkedIn to stay up to date with the latest articles.



ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 9 Comments

  1. JFC thank you for this! You’d think a simple step-by-step process like this would be documented on the MS site instead comes up with a nightmare fueled set of instructions that would shame a Stephen King novel. It took 45 minutes of googling to find the FOUR powerhell (not a typo) commands to connect to EOL …

  2. It’s like they try and make it as convoluted and unintuitive as possible. “Here’s a 17 step process to access features that really should be available in the portal, but aren’t”

  3. Do you know where I can find the module?

    The Gallery site has been down for days… 🙁


Leave a Reply

Your email address will not be published.