Exchange 2019: Managing your mailboxes with PowerShell

If security is a concern for you, you have most likely stopped the Exchange admin center from being published to the Internet and disabled access. So, how do you manage your mailboxes in Exchange 2019? The simple answer: You can manage your Exchange mailboxes with PowerShell.

The Exchange Management Shell (EMS) has many cmdlets for managing mailboxes; these include but are not limited to:

  • Creating new user mailboxes.
  • Adding/editing email addresses.
  • Configuring email forwarding.
  • Setting mailbox message size limits.
  • Managing storage.
  • Disabling user mailboxes.
  • Deleting user mailboxes.
  • Set Out of Office for a mailbox.

We will go through each option listed above and give you examples using PowerShell for each one so you can easily manage your Exchange mailboxes. You will notice that some commands are pretty straightforward and others are longer, but that is how you learn. Let’s proceed, and we will briefly explain each cmdlet mentioned below.

exchange powershell

Creating new Exchange user mailboxes with PowerShell

To create a mailbox using the Exchange Management Shell is relatively straightforward. Here is a command to create a new mailbox. The password here is for demonstration purposes — please use something a lot stronger:

New-Mailbox -Name "User New" -UserPrincipalName [email protected] -Password (ConvertTo-SecureString -String 'Pass.123' -AsPlainText -Force) -FirstName User -LastName New

The next piece in this section is creating a mailbox for a user who already exists in Active Directory. To enable a mailbox, simply run the command below:

Enable-Mailbox -Identity [email protected] -Database Store1

If you have a whole list of mailboxes to enable, you can find all the user accounts in Active Directory that are not mail-enabled and create mailboxes for them. Take note we are not touching system accounts. Here is the command:

Get-User -RecipientTypeDetails User -Filter "UserPrincipalName -ne `$null" -ResultSize unlimited | Enable-Mailbox

There you have your first set of commands that you can copy and add to your OneNote collection. Let’s move onto the next section.

Adding email addresses

In your organization, you may find that there is a sister company or an acquisition that has been made, and you need to add a second email alias to a mailbox. You can do so by running the following command:

Set-Mailbox "Edward 2" -EmailAddresses @{add="[email protected]"}

You can take this a step further. If you want to add multiple addresses, you can do so using this command:

Set-Mailbox "Edward2" -EmailAddresses @{add="[email protected]","[email protected]"}

You can see that we are using “add” in the command. If you don’t do this, it will overwrite the existing addresses, so be aware of that.

Configuring email forwarding

Email forwarding on a mailbox can be enabled when a user goes on leave and another person in the same department needs to step in. Or you have a user who wants all email forwarded to their personal email address — yes, this has been requested. You have the option of delivering the mailbox to the current user and then forwarding it. To do this, you can run the following command:

Set-Mailbox -Identity "Marketing User1" -DeliverToMailboxAndForward $true -ForwardingSMTPAddress "[email protected]"

Setting mailbox message size limits

In your organization, you might have a user in Marketing who needs to send larger mails than the rest of the company’s users or users in the Finance department as they deal with statements, financial documents, and more large mail items. You can set this per mailbox with the command below:

Set-Mailbox -Identity "Finance User" -MaxSendSize 35mb -MaxReceiveSize 45mb

Managing storage

Back in the day, users were granted 100MB mailboxes, some even smaller, and this didn’t allow for much growth or saving of email in mailboxes. As time changed and storage became more abundant, companies increased user mailboxes, and you now have some that are standard 50GB or 100GB mailboxes. To change the quota on a user’s mailbox, you can run the following command:

Set-Mailbox -Identity "User5 New " -IssueWarningQuota 100gb -ProhibitSendQuota 99.75gb -ProhibitSendReceiveQuota 100gb -UseDatabaseQuotaDefaults $false

In the command above, you can see that we chose not to use the database quota defaults, as this could be set to 10GB for a user.

Disabling user mailboxes

exchange powershell

Disabling a mailbox in Exchange lets you keep the Active Directory account instead of deleting the mailbox, which removes the account and mailbox. If you want to disable the mailbox for a user, you can run the following command:

Disable-Mailbox edward2

Take note that if you do not force the databases to update immediately, you won’t see the disconnected mailbox until Exchange has done its cleanup. The same applies to deleted user accounts.

Deleting user mailboxes

You may find that you have user mailboxes that are dormant in your organization and have not been used for a long time. You can delete those mailboxes (obviously, check with compliance regarding the data, etc.). To delete the mailbox, you can run the following command:

Remove-Mailbox [email protected]

Set Out of Office

You may be wondering why this is on the list. Well, you may have a user who is sick and is on unplanned leave or a user who was suspended. In this case, you may be requested to set the Out of Office as outlined by the manager for that department. Here is a sample command of how you can set this:

Set-MailboxAutoReplyConfiguration -Identity edward -AutoReplyState Enabled -InternalMessage "Type your text here that internal staff members will see." -ExternalMessage "Type your text here that external people will see"

If you do not know the time period, setting it like this will remain on the user’s mailbox. If you do know the end time, you can then specify the -StartTime and -EndTime parameters in the command.

There are many other options to manage your Exchange mailboxes you can set using the Set-Mailbox PowerShell cmdlet, but that is out of scope for this article. I wanted to show you the basics and how to get working with PowerShell and managing Exchange user mailboxes.

Featured image: Shutterstock

About The Author

Leave a Comment

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top