Goodness in Updated Module
On September 21, Microsoft released V2.0.3 of the Exchange Online Management PowerShell module to general availability. This is an update of what’s sometimes called Exchange Online PowerShell V2 (introduced at Ignite 2019). V2.0.3 was in preview for several months to work out bugs and validate new code. It contains some useful enhancements which makes it a candidate for a fast update.
The case for using the Exchange Online Management module instead of the older remote PowerShell cmdlets has been made many times. By now it should be a no-brainer, especially with Microsoft’s avowed intention to remove basic authentication for PowerShell in mid-2021 and the consequent need to upgrade interactive PowerShell sessions and background scripts to use modern authentication. Here are the highlights contained in V2.0.3.
The Exchange Online Management module comes with full support for modern authentication, multi-factor authentication, and now (in this version), certificate-based authentication (CBA) to allow scripts to run unattended as background jobs. Certificates can be stored in the certificate store of the local machine or current user. You can also use the CertificateFilePath parameter for the Connect-ExchangeOnline cmdlet to specify the file path to a .pfx file for a certificate. For more information, see this page.
Following previous releases of the module, I complained bitterly that running the Connect-IPPSession cmdlet to connect to the Security and Compliance endpoint removed the session connected to Exchange Online. In other words, you couldn’t do something like run Get-ExoMailbox to fetch a list of mailboxes, then run Connect-IPPSession, do some work, and then run Get-ExoMailbox again. I may have used some bad words to fully express my opinion on the inanity of this approach.
The developers listened and V2.0.3 includes support for simultaneous connections to Exchange Online and the Security and Compliance endpoints.
One of the original characteristics of using the REST-based cmdlets like Get-ExoMailbox or Get-ExoMailboxStatistics was a need to “warm up” the connection. In other words, it took a while for the first connection to be established and ready for use. Microsoft says that V2.0.3 is much faster at making the initial connection and in practice it seems like the improvement is marked. Results will vary depending on the cmdlet and number of objects in the tenant, but the connections are certainly snappier than before.
Limited Cmdlet Imports
Only 17 cmdlets are in the Exchange Online Management module, but when you connect to Exchange Online, over 700 cmdlets are imported into the session, all of which demand some memory. If you want to restrict memory usage to a minimum, you can specify the list of cmdlets needed by a session or script when you run the Connect-ExchangeOnline cmdlet. For example, this command will create a session with the 17 cmdlets from the module plus two imported from Exchange Online:
Connect-ExchangeOnline -CommandName Set-Mailbox, Set-CASMailbox
After the session starts, you will only be able to run Set-Mailbox and Set-CASMailbox from the set available for Exchange Online. Other cmdlets like Get-PublicFolder, New-TransportRule, or Get-UnifiedGroup are unavailable.
Take Care with Updates
When you do update the Exchange Online Management module, make sure that you include the Scope parameter to force the install of the module files onto the local disk. Otherwise you might end up like me and have some modules in OneDrive for Business and others local, with all the confusion that entails. After removing all traces of previous versions to give myself a clean start, I ran:
Install-Module ExchangeOnlineManagement -Scope AllUsers -Force
To check that the module is in the right place, run the command below and make sure that the module isn’t located in OneDrive for Business:
Get-Module ExchangeOnlineManagement | Select Path Path ---- C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.3\ExchangeOnlineManag...
New Preview Version
Microsoft has also released a new preview version of the Exchange Online Management module. Version 2.0.4-Preview2 includes all the functionality of 2.0.3 and has support for:
- PowerShell Core (PowerShell 7+).
- Exchange Online management from Linux devices.
- A new InlineCredential parameter for the Connect-ExchangeOnline cmdlet to allow passing of credentials to accounts that are not MFA-enabled without needing to store credentials in a script.
For more information and lots of examples of using PowerShell to manage Exchange Online, subscribe to the Office 365 for IT Pros eBook.