We have to offboard a mailbox from Exchange Online to Exchange on-premises. After following the…
How to install Exchange Online PowerShell V3 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 V3 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 V3 module.
Table of contents
- Exchange Online PowerShell module
- Install Exchange Online PowerShell V3 module
- Connect to Exchange Online PowerShell V3
- Exchange Online PowerShell V3 new cmdlets
- Disconnect Exchange Online
Exchange Online PowerShell module
The Exchange Online PowerShell module (abbreviated as the EXO V3 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 V3 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 V3 module.
Some key points about EXO V3 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 V3 cmdlets are REST API-based which are much faster and more reliable
- EXO V3 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 V3 module
Before we can install Exchange Online PowerShell V3 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 http://go.microsoft.com/fwlink/?LinkID=135170. 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 '18.104.22.168' 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 22.214.171.124 -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 get 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 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
Connect to Exchange Online PowerShell V3
Connect to Exchange Online PowerShell using the EXO V3 module with or without MFA.
Note: 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 email@example.com
In the sign-in window that opens, enter your password, and then click 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.
After the verification succeeds, you will return to the PowerShell window, and the below text will appear in a banner.
---------------------------------------------------------------------------------------- This V3 EXO PowerShell module contains new REST API backed Exchange Online cmdlets which doesn't require WinRM for Client-Server communication. You can now run these cmdlets after turning off WinRM Basic Auth in your client machine thus making it more secure. Unlike the EXO* prefixed cmdlets, the cmdlets in this module support full functional parity with the RPS (V1) cmdlets. V3 cmdlets in the downloaded module are resilient to transient failures, handling retries and throttling errors inherently. However, REST backed EOP and SCC cmdlets are not available yet. To use those, you will need to enable WinRM Basic Auth. For more information check https://aka.ms/exov3-module ---------------------------------------------------------------------------------------- PS C:\>
If you don’t want to show the screen output when connecting to Exchange Online, use the -ShowBanner switch. This will hide the banner, as seen above.
PS C:\> Connect-ExchangeOnline -UserPrincipalName firstname.lastname@example.org -ShowBanner:$false
Now we are connected to Exchange Online PowerShell and ready to type in the new cmdlets.
Exchange Online PowerShell V3 new cmdlets
See the list of new and old cmdlets.
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 V3 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 V3 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
You learned how to install Exchange Online PowerShell V3. Connect to Exchange Online PowerShell using the Exchange Online PowerShell V3 module with or without MFA. After connecting to Exchange Online, you can use the new cmdlets.