How to remove mailboxes from Exchange Online
This article lists the steps to use PowerShell to delete mailboxes from Exchange Online or Office 365 and also compares it with ADManager Plus, a unified Active Directory, Office 365 and Exchange management and reporting tool, to demonstrate why PowerShell is complex.
Steps to use PowerShell to delete Exchange Online mailbox.
- Ensure you have the necessary permissions to delete the mailbox.
- Get the name of the user account to which this mailbox belongs, and also decide if you wish to delete the mailbox permanently right away.
- Create the script with these values.
- Execute the script in the PowerShell window.
A sample script to remove mailbox from Exchange Online using PowerShell
Click to copy entire script
Remove-Mailbox -Identity "John Smith"
The script used above shows to use PowerShell to delete mailbox in Exchange Online. If you wish to use PowerShell to delete mailboxes from CSV in bulk, you cannot use the same script.
Limitations of using PowerShell to Remove Mailboxes from Exchange Online
- To delete an Exchange Online mailbox, you must have the necessary permissions. With ADManager Plus, users privileges in native AD or Exchange doesn't have to be elevated, and they can be allowed to do this operation only in specific OUs or domains.
- To bulk delete Exchange Online mailboxes, the script has to be modified. With ADManager Plus though, it is offered as a built-in option that's available by default.
- You must know how to execute the scripts from the PowerShell window or command line. ADManager Plus is purely GUI-based, allowing you to perform all management and reporting actions with just mouse clicks from its web-based console.
- Even a misplaced hyphen, a typo in the LDAP names or lack of sufficient permissions will lead to errors. As all actions in ADManager Plus are GUI-driven, there is no need to write scripts, eliminating the chances of errors.