No Search Result

Managing User Mailboxes with PowerShell

By Lazy-Fixer・ Published in powershellFebruary 1, 2025・ 1 min read

Managing User Mailboxes with PowerShell

Managing user mailboxes in Microsoft Exchange or Exchange Online (Microsoft 365) is an essential task for administrators. PowerShell provides a powerful way to automate and streamline mailbox management. This guide covers essential PowerShell cmdlets for managing user mailboxes effectively.

Prerequisites

Before you start, ensure you have the necessary permissions and modules installed:

On-Premises Exchange:

  • Open the Exchange Management Shell (EMS).
  • Use administrative privileges to run commands.

Exchange Online (Microsoft 365):

  • Install and connect to the Exchange Online module:
Install-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com

Viewing Mailbox Information

To list all mailboxes in your organization:

Get-Mailbox

To get detailed information about a specific user:

Get-Mailbox -Identity user@yourdomain.com | Format-List *

Creating a New Mailbox

To create a new mailbox for a user in on-premises Exchange:

New-Mailbox -Name "John Doe" -UserPrincipalName john.doe@yourdomain.com -Password (ConvertTo-SecureString -String "P@ssword123" -AsPlainText -Force)

For Exchange Online, assign a license first using Microsoft 365 Admin Center or PowerShell:

New-Mailbox -UserPrincipalName john.doe@yourdomain.com -Alias johndoe

Modifying Mailbox Properties

To update mailbox properties, such as display name or email address:

Set-Mailbox -Identity john.doe@yourdomain.com -DisplayName "Johnathan Doe"

To enable or disable mailbox features, such as OWA (Outlook Web Access):

Set-CASMailbox -Identity john.doe@yourdomain.com -OWAEnabled $false

Managing Mailbox Permissions

To grant another user full access to a mailbox:

Add-MailboxPermission -Identity john.doe@yourdomain.com -User admin@yourdomain.com -AccessRights FullAccess

To remove permissions:

Remove-MailboxPermission -Identity john.doe@yourdomain.com -User admin@yourdomain.com -AccessRights FullAccess

Setting Mailbox Forwarding

To forward emails from one mailbox to another:

Set-Mailbox -Identity john.doe@yourdomain.com -ForwardingSMTPAddress user@anotherdomain.com -DeliverToMailboxAndForward $true

To disable forwarding:

Set-Mailbox -Identity john.doe@yourdomain.com -ForwardingSMTPAddress $null

Managing Mailbox Size Limits

To check mailbox size limits:

Get-Mailbox -Identity john.doe@yourdomain.com | Select-Object ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota

To increase the size limit:

Set-Mailbox -Identity john.doe@yourdomain.com -ProhibitSendQuota 10GB -ProhibitSendReceiveQuota 12GB -IssueWarningQuota 9GB

Deleting or Disabling a Mailbox

To disable a mailbox but retain the user account:

Disable-Mailbox -Identity john.doe@yourdomain.com

To remove a mailbox completely:

Remove-Mailbox -Identity john.doe@yourdomain.com

Conclusion

Using PowerShell to manage user mailboxes helps administrators efficiently handle large-scale mailbox operations, saving time and effort. By leveraging these cmdlets, you can automate everyday tasks and maintain your Exchange environment effectively.

For more advanced PowerShell scripts, check Microsoft’s official documentation or the Exchange Online PowerShell reference guide.