Introduction to the new Exchange Online V2 Cmdlets
Table of Contents

The new set of cmdlets in the Exchange Online V2 Module proves to be a boon and somewhat of a bane for those engineers that move mailboxes to Exchange Online or manage Exchange Online in general.
They are a boon because the nine new cmdlets are simply more robust and faster than their predecessors. They are also a bane because they will require script re-coding as well as learning the new methodologies (PropertySets and Properties) that are now present in these cmdlets.
Overall Microsoft has sought to balance use, speed and compatibility with the previous PowerShell module for Exchange Online.
In order to use the new Exchange Online V2 Module, we need to make sure that we meet certain prerequisites. Let’s dive into that first.
Prerequisites
- NuGet – version 2.8.5 or newer
- PsGallery – Trusted PS Repository
- PackageManagement – needs to be v.x
- PowerShell Get – should be v.x or greater
Let’s break down the installation for each of these components.
A basic install would look something like this:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$False
If we wanted to verify NuGet needs to be installed, we can also verify the version installed or if any version is installed, like so:
$PackageProviders = (Get-PackageProvider -ListAvailable).Name
If ($PackageProviders -NotContains 'NuGet') {write-host 'NuGet is missing.'}
Now if NuGet is missing, then we run the installation code above, if however, NuGet is installed, we can force an installation of the correct, minimum version using the previous cmdlet either way.
More Information on NuGet.
Notice that the build numbers go all the way up to 2.12.1, but we only need to have 2.8.3 or higher.
PSGallery – Trusted Repository
In the case of the Microsoft Exchange Online PowerShell V2 Module, we need access to this repository in order to download the module. By default, this repository may not be trusted and as such we will need to make sure that it is. First, let’s verify if it is or not trusted from our workstation:
(Get-PSRepository -Name "PSGallery").InstallationPolicy
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Then we can verify the change: (Get-PSRepository -Name "PSGallery").InstallationPolicy
Tip: Always verify the change to prevent any future errors, especially with dependent processes.
PackageManagement
For PackageManagement we need to make sure that we have at least version 1.4.5. Let’s check this with PowerShell:
Get-Package PackageManagement -MinimumVersion 1.4.5
If PackageManagement is not installed, we will get an error like this:
In order to install PackageManagement properly, we may need to perform some gymnastics. That is because there are dependencies that can cause the upgrade process to hiccup. However, if all goes well, this is the only line we need to install PackageManagement:
Install-Module PackageManagement -Force -SkipPublisherCheck
Then when we verify the installation we see this:
Notice that the “Source” for this package is the PowerShell Gallery which we allowed earlier.
PowerShell Get
In addition to the previous package management software, we also have a module that will allow Admins to discover, install and update PowerShell modules, DSC resources, scripts and more. This is the last prerequisite for installing the EXO V2 module.
How do we install it? First, do we have it installed? We only need version 2 or higher, so we will check to see if we have a module installed whose Major version is 2:
[int32]((Get-Module PowerShellGet).Version).Major
Now, let’s upgrade this to at least 2.0:
Install-module PowerShellGet -MinimumVersion 2.0.0.0 -Force -Confirm:$False -SkipPublisherCheck
If all goes as planned, we can verify our new version and see this:
Wait. What? This should be two now. What happened? Is the package updated on our machine now?
Get-Package PowerShellGet
OK. So, we have the right version, why was 1 displayed in our check? That’s because the module that is loaded is the old one. Well, that is an easy fix:
We see now that 2.x of PowerShellGet is loaded and ready for us. Now onto downloading the module:
Download EXO V2 Module
Install-Module ExchangeOnlineManagement
Verify it is installed: Get-InstalledModule ExchangeOnlineManagement

Fig. 8: The output of “Get-InstalledModule” shows that the new EXO V2 Module is installed
Note: Your version may vary by the time you read this as 2.0.4 is the current version as of the writing of this article. However, in the past year or so this version has changed multiple times, as this screenshot of the version history shows:
Exchange Online V2 Cmdlets
Connect-ExchangeOnline
We are prompted for MFA or at least Modern Auth like other modules for Office 365. Before connecting we see this informational blurb:The module provides replacements for nine cmdlets, but also continues to provide the other 700+ original cmdlets from the original Exchange Online module that we have used for many years.
When we review our loaded modules, we see the new one on the top of the list, but we also see the original cmdlets listed in the last module (figure 11).

Fig. 11: Get-Module gives us an overview of the available modules and the cmdlets they contain
Free PowerShell Scripts
ActionPack for Microsoft Exchange Online
Download our free PowerShell script collection for managing distribution groups, mailboxes, resources, and services with Microsoft Exchange Online.
Why use the Exchange Online V2 cmdlets?
- Reducing Data: Traditional PowerShell cmdlets return all data, even if all the data is not displayed. The EXO V2 cmdlets only return a subset of the data, which may challenge an admin to determine what they need.
- Property Sets: Grouped sets of data that can be returned by PowerShell cmdlets.
- Speed: With the two previous examples, combined they provide some additional speed and reliability for the nine new cmdlets.
These cmdlets were chosen for two reasons – most likely to be used, but also the most likely to be slow or fail due to the amount of data returned and the load put on Exchange Online servers.
Change in Operation
When using these cmdlets, it is important to note that we do indeed need to be aware of syntax and proper usage of the new parameters in order to get the correct data in Exchange Online.
Property Sets Example:
Old Method
Get-Mailbox | Where {$_.IsResource -eq 'True'} | Ft Name, Alias, PrimarySMTPAddress, *quota
New EXO V2 Method
With the new cmdlets, we need to rely on either PropertySets like this:
Get-EXOMailbox -PropertySets Minimum, Resource, Quota | Where {$_.IsResource -eq 'True'} | ft
Properties Example:
Get-EXOMailbox -Properties Name,Alias,PrimarySMTPAddress, IsResource, IssueWarningQuota,ProhibitSendQuota, ProhibitSendReceiveQuota | Where {$_.IsResource -eq 'True'} | ft
While this provides the same results, it is already becoming quite unwieldy. Thus, choosing between Properties and PropertySets should be based on how many attributes one would need to display.
How do we tell which parameters/properties are usable with a Property Set? It is not documented in Get-Help or in the online help of Microsoft Docs. Let’s take for example Get-EXOMailbox from the previous example. We can see the list of all Property Sets listed in Get-Help for the cmdlet:
If we were looking for all Quota attributes, we see that there is a Quota Property. Using this reveals a lot of properties for an account:
Get-EXOMailbox Ted -PropertySets Quota
Notice that there are some properties that are not Quota related but instead are identifiers for the mailbox – UserPrincipalName, PrimarySMTPAddress and Identity. What are the minimum reported properties? Let’s review the example below as the default (no specified PropertySets) is “Minimum”:
Get-EXOMailbox Ted
Real World Experience with EXO V2 cmdlets
- Fewer Timeouts – on a dataset of 7,000 mailboxes, the new EXO V2 cmdlets were able to query all mailboxes, looking at each folder and finding a large number of items in folders (100k+) without timing out. With the older cmdlets, this would have failed.
- Speed – The EXO v2 cmdlets do run much faster. We have a query performed with both Get-Mailbox and Get-EXOMailbox:
- Get-Mailbox [full run, unlimited results, 7,600+ mailboxes]:
Fig. 14: Execution time using Get-Mailbox
- Get-EXOMailbox [Full run, unlimited results, 7,600+ mailboxes]:
Notice that the EXO V2 cmdlet is about twice as fast as the regular cmdlet. Your experience will vary depending on your environment, but in general it should be much faster and responsive.Fig. 15: Execution time using Get-EXOMailbox
- Get-Mailbox [full run, unlimited results, 7,600+ mailboxes]:
Conclusion
Related links
- About the Exchange Online PowerShell V2 module | Microsoft Docs
- NuGet Gallery | NuGet.Build 2.12.1
- Property sets in Exchange Online PowerShell V2 cmdlets | Microsoft Docs
- Filters in the EXO V2 module | Microsoft Docs
- ScriptRunner ActionPack for ExchangeOnline on GitHub
- Use Case: Delegate Out-of-Office Settings and Auto-Replies in Exchange
- Webinar: Automation and delegation of Exchange/O365 administrative tasks with PowerShell
Related posts
7 min read
How ChatGPT and AI Will Change the Way We Build PowerShell Scripts – Forever
May 4, 2023 by Doug Finke
6 min read
The best PowerCLI commands for admins – part 1: VM inventory management
May 4, 2023 by Philip Lorenz
About the author:
Damian Scoles is a ten-time Microsoft MVP specializing in Exchange, Office 365 and PowerShell who has 25 years of IT industry experience. He is based in the Chicago area and started out managing Exchange 5.5 and Windows NT. Over the years he has worked with Office 365 since BPOS and his experience has grown to include Azure AD, Security and Compliance Admin Centers, and Exchange Online. His community outreach includes contributing to TechNet forums, creating PowerShell scripts that can be found on his blogs, writing in-depth PowerShell / Office365 / Exchange blog articles, tweeting, and creating PowerShell videos on YouTube. He has written five PowerShell books and is also actively working on the book "Microsoft 365 Security for IT Pros".
Latest posts:
- Automate snapshots and templates with PowerCLI – Part 2
- How ChatGPT and AI Will Change the Way We Build PowerShell Scripts – Forever
- The best PowerCLI commands for admins – part 1: VM inventory management
- The Tools You Need When Troubleshooting Active Directory
- ScriptRunner Portal Edition R5 – Mission Accomplished