Blog Post

Microsoft Mission Critical Blog
4 MIN READ

Optimizing Exchange Online PowerShell

erscofie's avatar
erscofie
Icon for Microsoft rankMicrosoft
Dec 11, 2025

Introduction

The Exchange Online PowerShell module is a powerful tool. As environments scale and tasks grow in complexity, performance and reliability become critical. This post takes a holistic approach to optimizing Exchange Online management and automation in four parts:

  1. Windows PowerShell performance tips
  2. Best practices that apply to all M365 PowerShell modules
  3. Best practices specific to the Exchange Online PowerShell module
  4. The future of automation
=================

General Windows PowerShell Performance Tips

 

Seemingly obvious but often overlooked, if you want to get peak performance from any PowerShell module, you need to optimize Windows PowerShell itself.

  • Keep PowerShell Updated: Always use the latest supported version of PowerShell for security, compatibility, and performance improvements.
    • Windows PowerShell 5.1 is preinstalled on the currently supported versions of Windows. Security updates and other patches are included in Windows Updates.
    • For PowerShell 7, follow the steps here.
  • Disable telemetry if not needed by setting the POWERSHELL_TELEMETRY_OPTOUT environment variable:
$env:POWERSHELL_TELEMETRY_OPTOUT = "true"
=================

Best Practices for all M365 PowerShell Modules

These best practices are vital for, but not specific to Exchange Online PowerShell. In other words, although I’ve used Exchange Online cmdlets in the examples provided, all tips in this section apply to other M365-specific modules like SharePoint, Teams, or Security and Compliance PowerShell.

  • Use the latest module version to benefit from performance improvements and bug fixes.
    • For Admins, establish a regular update cadence for all M365 PowerShell modules. Testing new releases on local machines or management servers is ideal for admins, as it offers flexibility and low risk if problems occur.
    • Leverage auto-updates for automation tools, if available. For example, the Managed Dependencies feature for Azure Functions Apps.

 

Script smarter, not harder…
  • Parallel Processing:
  • Use -ResultSize to return only the necessary data. This is especially beneficial when querying many objects.
Get-EXOMailbox -ResultSize 100

This example retrieves only the first 100 mailboxes (rather than default of 1,000), reducing resources and time to execute.

 

  • Prioritize service-side filtering when available. Not all filters are created equal. Understanding how, or more importantly, where filtering is done when using different methods can have a substantial impact on performance.
    • Experienced PowerShell users know about pipelining with Where-Object to filter data. This is one example of client-side filtering.
    • Most cmdlets available in the various M365 PowerShell modules support the -Filter parameter. This leverages service-side (a.k.a. server-side) filtering.
Get-EXOMailbox -Filter "Department -eq 'Sales'"

This example limits results to mailboxes for the sales department and leverages service-side filtering to ensure only the data we want is returned to the client.

 

Service-side filtering is much more efficient for several reasons. A deep-technical explanation of this is outside the scope of the current post, so you can take my word for it or seek out more information for yourself. There are plenty of great, easy to find articles across the web on this topic.

 

Following the above recommendations helps ensure that we, the users (and our tools), have a solid foundation for optimal performance. Next, let’s look at ways to ensure we get the best performance out of the Exchange Online module itself.

=================

Exchange Online PowerShell (EXO)

 

The Exchange Online PowerShell module (EXO V3+) introduced significant performance improvements, especially around how cmdlet help files are handled.

  • Use the Exchange Online V3 Module: The latest module supports REST-based cmdlets, offering better performance and reliability.

How much better and more reliable? I thought you’d never ask…

From REST API connections in the EXO V3 module:

The following table compares the benefits of REST API cmdlets to unavailable remote PowerShell cmdlets and the exclusive Get-EXO* cmdlets in the EXO V3 module

 

 

Remote PowerShell cmdlets (deprecated)

Get-EXO* cmdlets

REST API cmdlets

Security

Least secure

Highly secure

Highly secure

Performance

Low performance

High performance

Medium performance

Reliability

Least reliable

Highly reliable

Highly reliable

Functionality

All parameters and output properties available

Limited parameters and output properties available

All parameters and output properties available

 

=================

The Future! Microsoft Graph PowerShell SDK

 

 

The Microsoft Graph PowerShell SDK is the future of Microsoft 365 automation. It’s modular, cross-platform, and supports modern authentication. Graph can feel overwhelming to those who are comfortable with the current PowerShell modules. If you haven’t started using Graph because you aren’t sure where to start, I recommend you Install the Microsoft Graph PowerShell SDK and check out our aptly named “Getting started” documentation (don’t look at me like that).

Better yet, if you’re a Support for Mission Critical customer, ask your Customer Success Account Manager or Customer Solution Lead about the Microsoft-led training options and learn from an expert!

If you’re already using the Microsoft Graph PowerShell SDK, great! The tips outlined throughout this post can provide the same benefits with Graph.

=================

✅ Final Thoughts

Optimizing PowerShell performance isn’t just about speed – it’s about reliability, scalability, and resource efficiency. Whether you’re using PowerShell for daily management or building and maintaining automation tools for your organization, following these guidelines should have immediate and lasting benefits.

Updated Dec 11, 2025
Version 1.0
No CommentsBe the first to comment