How to Set Up and Use ExchangeOnlineManagement in PowerShell

Creation date: 9/8/2025 8:15 AM    Updated: 9/8/2025 10:45 AM   exchange exchange online management powershell

Overview

The ExchangeOnlineManagement module is the official PowerShell module for managing Exchange Online in Microsoft 365. It supports modern authentication, including MFA, and provides REST-based cmdlets for better performance.

Prerequisites

· Windows PowerShell 5.1 or PowerShell 7+ (cross-platform).

· PowerShellGet and PackageManagement modules installed.

    - Install-Module PowerShellGet -Force

    - Install-Module PackageManagement -Force

· Exchange Online admin permissions.


Step 1: Install the Module

Run PowerShell as Administrator and execute:

Install-Module -Name ExchangeOnlineManagement

Get-Module ExchangeOnlineManagement -ListAvailable


Step 2: Import the Module

Import-Module ExchangeOnlineManagement


Step 3: Connect to Exchange Online

Interactive Login (with MFA):

Connect-ExchangeOnline -UserPrincipalName yourUPN@domain.com

Device Login (PowerShell 7):

Connect-ExchangeOnline -Device


Step 4: Common Cmdlets

List all mailboxes:

Get-Mailbox

Check mailbox size:

Get-MailboxStatistics -Identity user@domain.com

Create a new mailbox:

New-Mailbox -Name "User Name" -MicrosoftOnlineServicesID user@domain.com -Password (ConvertTo-SecureString -String 'Password123' -AsPlainText -Force)


Step 5: Disconnect

Disconnect-ExchangeOnline -Confirm:$false


References

Microsoft Learn: Connect to Exchange Online PowerShell

https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps