In a previous article, I explained how to connect to Office 365 with PowerShell. In this article, we explore how to use PowerShell to connect to Exchange Online.
Note: This article only covers the PowerShell v2 and v3 modules. Exchange Online PowerShell v1 module was removed from this article as it is deprecated as of October 1st, 2022, with the deprecation of basic authentication.
Let’s get started!
Exchange Online PowerShell Module
One of the challenges of a large Exchange Online organization is that PowerShell commands can take a very long time to run. The Exchange Team released the Exchange Online PowerShell V2 module to combat this problem, which ships with all new Exchange cmdlets while still supporting the old cmdlets. Microsoft has determined that these new cmdlets are up to eight times faster in certain instances. I highly recommend using this module over the V1 module. The V2 module has been generally available since June 2020.
To use the new Exchange Online module, launch PowerShell as an administrator and run the following command.
C:\> Install-Module ExchangeOnlineManagement
If you did not have NuGet previously installed from another PowerShell library you will be prompted to install it. Press Y and hit Enter.
NuGet provider is required to continue. PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\<user>\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y[Read more…] about Easily Connect to Exchange Online with PowerShell