Exchange ServerMicrosoftPowershellWindows Server

15 Exchange Server PowerShell Commands Every Admin Should Know


Microsoft Exchange Server is a powerful email and collaboration platform widely used in enterprises worldwide. While the Exchange Admin Center provides a user-friendly graphical interface, many administrators prefer the flexibility and automation capabilities offered by PowerShell. PowerShell cmdlets allow you to perform a wide range of tasks, from managing mailboxes and distribution groups to configuring transport rules and monitoring server health. In this article, we’ll explore 15 essential Exchange Server PowerShell commands that every admin should have in their toolkit.


The Get-Mailbox cmdlet is a versatile command that retrieves information about mailboxes in your Exchange organization. It allows you to filter mailboxes based on various criteria, such as mailbox type, database, or server. This cmdlet is particularly useful for gathering mailbox statistics, checking mailbox properties, and performing bulk operations.


# Get all mailboxes in the organization

# Get mailboxes with a specific database
Get-Mailbox -Database "DB01"

# Get mailbox statistics
Get-Mailbox -Identity "" | Select-Object DisplayName, DatabaseName, TotalItemSize


As the name suggests, the New-Mailbox cmdlet creates new mailboxes in your Exchange environment. It supports various mailbox types, including user mailboxes, room mailboxes, and shared mailboxes. You can specify mailbox properties, such as database, alias, and address book policies, during mailbox creation.


# Create a new user mailbox
New-Mailbox -UserPrincipalName "" -Alias "user" -Database "DB01" -Name "John Doe" -OrganizationalUnit "ou=Users,dc=domain,dc=com"

# Create a new room mailbox
New-Mailbox -Room -Name "Conference Room" -Database "DB01" -EmailAddresses ""


The Set-Mailbox cmdlet allows you to modify the properties of existing mailboxes. You can change mailbox settings, such as mailbox quotas, retention policies, and delivery options. This cmdlet is essential for managing mailbox configurations and ensuring compliance with organizational policies.


# Set mailbox quota
Set-Mailbox -Identity "" -IssueWarningQuota 20GB -ProhibitSendQuota 24GB -ProhibitSendReceiveQuota 25GB

# Enable mailbox auditing
Set-Mailbox -Identity "" -AuditEnabled $true


The Add-MailboxPermission cmdlet grants permissions to users or security groups to access a specific mailbox. This is particularly useful for shared mailboxes or when delegating access to another user’s mailbox for administrative or support purposes.


# Grant full access to a user's mailbox
Add-MailboxPermission -Identity "" -User "" -AccessRights FullAccess -InheritanceType All

# Grant send-as permission to a distribution group
Add-MailboxPermission -Identity "" -User "" -AccessRights SendAs


The Get-MailboxStatistics cmdlet retrieves detailed statistics about mailboxes, including item counts, mailbox sizes, and last access times. This information is invaluable for monitoring mailbox usage, identifying potential issues, and planning storage requirements.

Recommended For You:  Deploying Hybrid Hyper-V Clusters with Azure and PowerShell: A Step-by-Step Guide


# Get mailbox statistics for all mailboxes

# Get mailbox statistics for a specific mailbox
Get-MailboxStatistics -Identity ""


The New-DistributionGroup cmdlet creates new distribution groups in your Exchange organization. Distribution groups are essential for email communication within teams or departments. You can create various types of distribution groups, including security groups and dynamic distribution groups.


# Create a new distribution group
New-DistributionGroup -Name "Sales Team" -Alias "sales" -MemberJoinRestriction Closed -MemberDepartRestriction Closed

# Create a new dynamic distribution group
New-DynamicDistributionGroup -Name "West Coast Employees" -RecipientFilter "Company -eq 'Contoso' -and StateOrProvince -eq 'CA,OR,WA'"


The Add-DistributionGroupMember cmdlet allows you to add members (users or other distribution groups) to an existing distribution group. This cmdlet is crucial for managing group memberships and ensuring that the right individuals receive relevant communications.


# Add a user to a distribution group
Add-DistributionGroupMember -Identity "Sales Team" -Member ""

# Add multiple users to a distribution group
$users = "", "", ""
Add-DistributionGroupMember -Identity "Sales Team" -Members $users


 The Get-TransportRule cmdlet retrieves information about transport rules configured in your Exchange organization. Transport rules are powerful tools that allow you to apply actions to incoming or outgoing messages based on specific conditions. This cmdlet helps you review and manage your transport rules.


# Get all transport rules

# Get a specific transport rule
Get-TransportRule -Identity "Block Attachments"


The New-TransportRule cmdlet creates new transport rules in your Exchange environment. Transport rules can perform various actions, such as blocking or redirecting messages, adding disclaimers, or applying message classifications based on predefined conditions.


# Create a transport rule to block attachments with specific file types
New-TransportRule -Name "Block Attachments" -AttachmentIsUnsupported "(?i)\.ade|\.adp|\.bat|\.chm|\.cmd|\.com|\.cpl|\.exe|\.hta|\.ins|\.isp|\.js|\.jse|\.lib|\.lnk|\.mde|\.msc|\.msp|\.mst|\.pif|\.scr|\.sct|\.shb|\.sys|\.vb|\.vbe|\.vbs|\.vxd|\.wsc|\.wsf|\.wsh" -RejectMessageReasonText "Attachment blocked due to security policy"

# Create a transport rule to apply a disclaimer to outgoing messages
New-TransportRule -Name "Disclaimer" -SentToScope "InOrganization" -ApplyHtmlDisclaimerLocation "Append" -HtmlDisclaimerText "<p>This message is confidential and intended for the recipient only.</p>"


The Test-MAPIConnectivity cmdlet tests the MAPI connectivity between a client and an Exchange server. This cmdlet is particularly useful for troubleshooting Outlook connectivity issues and identifying potential problems with mailbox access.


# Test MAPI connectivity for a specific mailbox
Test-MAPIConnectivity -Identity ""

# Test MAPI connectivity for all mailboxes on a specific database
Get-Mailbox -Database "DB01" | Test-MAPIConnectivity


The Get-MessageTrackingLog cmdlet retrieves message tracking logs from your Exchange environment. These logs provide detailed information about the delivery status of email messages, including sender, recipient, and any errors or delays encountered during the delivery process.


# Get message tracking logs for a specific sender
Get-MessageTrackingLog -Sender ""

# Get message tracking logs for a specific recipient
Get-MessageTrackingLog -Recipients ""


The Get-TransportService cmdlet retrieves information about the transport services running on your Exchange servers. Transport services are responsible for handling message delivery and routing within your organization. This cmdlet helps you monitor the status of these services and identify potential issues.

Recommended For You:  Choosing the Right Hyper-V Storage Type: Insights Through PowerShell


# Get transport services on all Exchange servers

# Get transport services on a specific server
Get-TransportService -Server "EX01"


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.


# Set maximum message size limit
Set-TransportConfig -MaxReceiveSize 25MB -MaxSendSize 25MB

# Add an accepted domain
Set-TransportConfig -AddressSpacesEnabled $true -AddressSpacesCostHybridRemoteGateway "Internet" -AddressSpacesInternal ""


The Get-MailboxDatabase cmdlet retrieves information about mailbox databases in your Exchange environment. This cmdlet provides valuable insights into database properties, such as database size, mounted server, and mailbox counts.


# Get all mailbox databases

# Get a specific mailbox database
Get-MailboxDatabase -Identity "DB01"


The Start-ManagedFolderAssistant cmdlet initiates the Managed Folder Assistant process, which applies retention policies to mailboxes. Retention policies help organizations comply with legal and regulatory requirements by automatically deleting or archiving older items based on predefined rules.


# Start the Managed Folder Assistant for a specific mailbox
Start-ManagedFolderAssistant -Identity ""

# Start the Managed Folder Assistant for all mailboxes
Get-Mailbox | Start-ManagedFolderAssistant


PowerShell cmdlets provide Exchange administrators with a powerful toolset for managing and automating various tasks within their Exchange environment. The 15 commands covered in this article are essential for mailbox management, distribution group administration, transport rule configuration, message tracking, and server monitoring. By mastering these cmdlets, administrators can streamline their workflows, ensure compliance, and maintain a healthy and efficient Exchange infrastructure.


  1. Can I use PowerShell to manage Exchange Online (Office 365) environments?Yes, the Exchange Online PowerShell module allows you to manage your Exchange Online environment using PowerShell cmdlets. You can connect to Exchange Online using the Connect-ExchangeOnline cmdlet.

  2. How can I automate repetitive tasks using PowerShell? PowerShell scripts allow you to automate repetitive tasks by combining multiple cmdlets and adding logic and control structures. You can create scripts to perform bulk operations, schedule recurring tasks, or automate complex workflows.

  3. What are the prerequisites for running Exchange PowerShell cmdlets? To run Exchange PowerShell cmdlets, you need to have the Exchange Management Shell installed on your machine. Additionally, you must have the appropriate permissions and roles assigned to your account to perform the desired tasks.

  4. Can I use PowerShell to manage hybrid Exchange environments? Yes, PowerShell cmdlets can be used to manage hybrid Exchange environments, which combine on-premises Exchange servers with Exchange Online. You can use the appropriate cmdlets for each environment, or use the Exchange Online Remote PowerShell Module to manage both environments from a single PowerShell session.

  5. How can I learn more about Exchange PowerShell cmdlets? Microsoft provides extensive documentation and resources for Exchange PowerShell cmdlets. You can refer to the Exchange Server PowerShell documentation [link], Exchange Online PowerShell documentation [link], and various blogs and forums dedicated to Exchange administration.

If you'd like to learn more, consider these helpful resources:

Muhammad Faizan

Hi, My name is Muhammad Faizan and i have spent last 15 years working as System Administrator mainly with Microsoft Technologies. I am MCSE, MCTP, MCITP, certified professional. I love scripting and Powershell is the scripting language i am in love with.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button