Removing Bulk Exchange Mailboxes via Powershell

Scenario:  You have a list of mailboxes that you wish to remove in bulk.

Resolution:  We will use the Remove-Mailbox command-let in order to perform this task.  We will remove it via a loop by reading in a CSV file with the mailboxes.  Note:  The Remove-Mailbox will disable the mailbox and delete the AD account.  If you wish to leave the AD Account but only disable the mailbox, use the Disable-Mailbox instead.

Create a CSV file with the names of the mailboxes
  1. Open Notepad
  2. On the first line, type in name
  3. On the second line and down, paste the mailbox names (one mailbox per line).
  4. Save it as Mailboxes.csv to a location you will remember

Import the CSV into a Exchange Variable
  1. Open Exchange Management Shell
  2. Type in the following: (Make sure to use the .csv file path from above)
       $mailboxes = Import-Csv ‘C:mailboxes.csv’
  3.  Verify that your Exchange Variable has content by typing in:

Remove the Mailboxes via a loop in Exchange Management Shell.
  1. Type in the following:
       $mailboxes | %{Remove-mailbox $ -confirm:$false }
  2. The Mailboxes and AD objects are now removed.

Alternate Methods:

1. Remove a Single Mailbox:    
     Remove-Mailbox jdoe1 -confirm:$false
2. Remove multiple mailboxes that follow a pattern in the mailbox name quickly:
     Get-mailbox jdoe* | Remove-mailbox -confirm $false



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: