Dela via


Remove-Mailbox

 

Applies to: Exchange Server 2007 SP1, Exchange Server 2007 SP2, Exchange Server 2007 SP3

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> [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-IgnoreDefaultScope <SwitchParameter>] [-Permanent <$true | $false>] [-WhatIf [<SwitchParameter>]]

Remove-Mailbox -Database <DatabaseIdParameter> -StoreMailboxIdentity <StoreMailboxIdParameter> [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-IgnoreDefaultScope <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

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.

Confirm

Optional

System.Management.Automation.SwitchParameter

The Confirm parameter causes the command to pause processing and requires you to acknowledge what the command will do before processing continues. You don't have to specify a value with the Confirm parameter.

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.

IgnoreDefaultScope

Optional

System.Management.Automation.SwitchParameter

The IgnoreDefaultScope parameter instructs the command to ignore the default recipient scope setting for the Exchange Management Shell and use the entire forest as the scope. This allows the command to access Active Directory objects that are not currently in the default scope. Using the IgnoreDefaultScope parameter introduces the following restrictions:

  • You cannot use the DomainController parameter. The command will use an appropriate global catalog server automatically.

  • You can only use the DN for the Identity parameter. Other forms of identification, such as alias or GUID, are not accepted.

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.

WhatIf

Optional

System.Management.Automation.SwitchParameter

The WhatIf parameter instructs the command to simulate the actions that it would take on the object. By using the WhatIf parameter, you can view what changes would occur without having to apply any of those changes. You don't have to specify a value with the WhatIf parameter.

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