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.

Information 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 ExecutionPolicy

By default, we can’t install scripts. Configure PowerShell to 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.

Important: Close and re-open the elevated Windows PowerShell window to get the changes from the previous steps.

Install the module PowerShellGet

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

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

Run PowerShell as administrator and run the following cmdlet. Press Y and Enter.

Connect to Exchange Online using Exchange Online PowerShell V2

Do you have MFA enabled on your account? Use option 1. If you don’t have MFA enabled, use option 2.

Option 1: Account with MFA enabled

It’s recommended to have MFA (Multi-Factor Authentication) enabled on the accounts. Connect with your admin account to Exchange Online. Run the cmdlet.

After running the cmdlet, the sign-in window shows up. Fill in your password and click Sign in.

Install Exchange Online PowerShell V2 enter password

In the verification window that opens, enter the verification code, and then click Verify.

Install Exchange Online PowerShell V2 enter MFA

You will get back to the PowerShell window and it’s showing the new cmdlets in a banner.

Option 2: Account without MFA enabled

Run the following cmdlet.

Enter credentials and click OK.

Install Exchange Online PowerShell V2 enter credentials

Connect to Exchange Online by running the cmdlet. This time you will not get another window asking to enter your code (MFA).

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

Exchange Online PowerShell V2 new cmdlets

See the list of new and old cmdlets.

Good to know

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.

Sign out from 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.

Connect to Exchange Online PowerShell

Do you like to know how to connect to Exchange Online PowerShell without using version 2? Read the articles that we already have covered for you.

Conclusion

In this article, you learned how to install Exchange Online PowerShell V2. There are two options to connect to Exchange Online with Exchange Online PowerShell V2. That’s with MFA enabled or without MFA enabled. After connecting to EXO, you can make use of the new cmdlets.

If you liked this article, you may also like to read Get mailbox permissions with PowerShell. Follow us on Twitter and LinkedIn to stay up to date with the latest articles.

ALI TAJRAN

ALI TAJRAN

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. Connect with ALI TAJRAN on social media. Read more »

This Post Has One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top