Remove-Mailbox (RTM)

Microsoft Exchange Server 2007 will reach end of support on April 11, 2017. To stay supported, you will need to upgrade. For more information, see Resources to help you upgrade your Office 2007 servers and clients.

 

Applies to: Exchange Server 2007

Use the Remove-Mailbox cmdlet to delete the user account that is associated with a particular mailbox from the Active Directory directory service and to process the associated, disconnected mailbox as directed by the specified parameters.

Syntax

Remove-Mailbox -Identity <MailboxIdParameter> [-DomainController <Fqdn>] [-Permanent <$true | $false>]

Remove-Mailbox -Database <DatabaseIdParameter> -StoreMailboxIdentity <StoreMailboxIdParameter> [-DomainController <Fqdn>]

Detailed Description

The Remove-Mailbox cmdlet removes from Active Directory the user account associated with a particular mailbox and then processes the associated, disconnected mailbox as directed by the parameters specified.

Use the Identity parameter alone to disconnect the mailbox from the user and remove the user object from Active Directory. The mailbox object still exists. By default, this mailbox will remain in the Exchange database for 30 days, and then will be deleted.

Use the Identity and Permanent parameters to disconnect the mailbox from the user, remove the user object from Active Directory, and remove the mailbox object from the Exchange database. The mailbox object will not remain in the Exchange database as a disconnected mailbox.

Use the Database and StoreMailboxIdentity parameters to remove a mailbox object from the Exchange database. In this case, the mailbox object has already been disconnected from the user. For example, if you run the Disable-Mailbox cmdlet, the Exchange mailbox object still exists, but is disconnected from the Active Directory user object. You can use the Database and StoreMailboxIdentity parameters to remove this disconnected mailbox object.

To run the Remove-Mailbox cmdlet,the account you use must be delegated the following:

  • Exchange Recipient Administrator role

  • Account Operator role for the applicable Active Directory containers

For more information about permissions, delegating roles, and the rights that are required to administer Exchange Server 2007, see Permission Considerations.

Parameters

Parameter Required Type Description

Database

Required

Microsoft.Exchange.Configuration.Tasks.DatabaseIdParameter

The Database parameter specifies the database that contains the mailbox object. You can use one of the following values:

  • GUID

  • Database name

  • Server name\database name

  • Server name\storage group\database name

If you do not specify the server name, the cmdlet will search for the database on the local server. If you have multiple databases with the same name on the same server, you must specify the storage group.

This parameter must be used in conjunction with the StoreMailboxIdentity parameter. The Database parameter cannot be used with the Identity parameter. If you have disconnected a mailbox from its associated user and want to remove the mailbox object from the Exchange store, use the Database and StoreMailboxIdentity parameters.

Identity

Required

Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter

The Identity parameter identifies the mailbox object that you want to remove. You can use one of the following values:

  • ADObjectID

  • Distinguished name (DN)

  • Legacy DN, GUID

  • Domain\Account name

  • User principal name (UPN)

  • E-mail address

  • Alias

The Identity parameter cannot be used with the Database parameter.

StoreMailboxIdentity

Required

Microsoft.Exchange.Configuration.Tasks.StoreMailboxIdParameter

The StoreMailboxIdentity parameter identifies the mailbox object to remove. The StoreMailboxIdentity parameter is used in conjunction with the Database parameter to remove the mailbox object from the Exchange database. If you have disconnected a mailbox from its associated user and want to remove the mailbox object from the Exchange store, use the Database and StoreMailboxIdentity parameters.

DomainController

Optional

Microsoft.Exchange.Data.Fqdn

The DomainController parameter specifies the domain controller that writes this configuration change to Active Directory. Use the fully qualified domain name (FQDN) of the domain controller that you want to use.

Permanent

Optional

System.Boolean

The Permanent parameter, when used in conjunction with the Identity parameter, disconnects the mailbox from the user, removes the associated user object from Active Directory, and removes the mailbox object from the Exchange database. The two possible values for this parameter are $true or $false. The default value is $false.

Input Types

Return Types

Errors

Error Description

 

Exceptions

Exceptions Description

 

Example

The first example shows how to disconnect the user John Peoples' (john) mailbox from the user account, and remove the mailbox object from Active Directory. The mailbox will remain in the Exchange database for the deleted mailbox retention period configured for the mailbox database.

The second example shows how to disconnect the user John Peoples' (john) mailbox from the user account, remove the mailbox object from Active Directory, and remove the mailbox from the Exchange database.

The third example shows how to remove John Peoples' (john) mailbox from the Exchange database, assuming the mailbox has already been disconnected from the user. The example show how to use the Get-MailboxStatistics cmdlet to retrieve the mailbox GUID value using the display name of the disconnected mailbox. This value is needed for the StoreMailboxIdentity parameter of the Remove-Mailbox cmdlet.

Remove-Mailbox -Identity contoso\john
Remove-Mailbox -Identity contoso\john -Permanent $true
$Temp = Get-MailboxStatistics | Where {$_.DisplayName -eq 'John Peoples'}
Remove-Mailbox -Database Server01\Database01 -StoreMailboxIdentity $Temp.MailboxGuid