Clean-MailboxDatabase

 

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

Use the Clean-MailboxDatabase cmdlet to scan the Active Directory directory service for disconnected mailboxes that are not yet marked as disconnected in the Microsoft Exchange store and update the status of those mailboxes in the Exchange store. This cmdlet is not able to update the Exchange store unless the Microsoft Exchange Information Store service is running and the database is mounted.

Syntax

clean-MailboxDatabase -Identity <DatabaseIdParameter> [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-WhatIf [<SwitchParameter>]]

Detailed Description

To run the Clean-MailboxDatabase cmdlet, the account you use must be delegated the Exchange Organization Administrator role.

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

A connected mailbox has two parts: the mailbox object in the Exchange store, and the user object with Exchange properties in Active Directory. A disconnected mailbox is the mailbox object in the Exchange store, but it is not connected to a user object in Active Directory. To disconnect a mailbox, use the Disable-Mailbox cmdlet. To disconnect a mailbox and remove the user object from Active Directory, use the Remove-Mailbox cmdlet.

If you want to reconnect a disconnected mailbox to an Active Directory user account, use the Connect-Mailbox cmdlet.

If you want to permanently remove a mailbox object from the Exchange store, use the Remove-Mailbox cmdlet.

Under normal circumstances, it is not necessary to run Clean-MailboxDatabase because a mailbox is marked as disconnected immediately after the Disable-Mailbox or Remove-Mailbox command completes. If you used the Disable-Mailbox cmdlet or the Remove-Mailbox cmdlet while the Exchange Information Store service was stopped, or if a mailbox was disabled by an external means other than the Disable-Mailbox cmdlet or Remove-Mailbox cmdlet, you may want to use the Clean-MailboxDatabase cmdlet to scan for disconnected mailboxes.

Note

You can run the Clean-MailboxDatabase cmdlet in Microsoft Exchange Server 2007 to achieve the same results as the Run Cleanup Agent action in the Exchange Server 2003 System Manager. To run the cleanup agent, in Exchange System Manager, expand Servers, expand the server name, expand the storage group name, expand the mailbox database name, right-click Mailboxes, and select Run Cleanup Agent.

For more information, see the following topics:

Parameters

Parameter Required Type Description

Identity

Required

Microsoft.Exchange.Configuration.Tasks.DatabaseIdParameter

The Identity parameter identifies the mailbox database that you want to update. You can use the following values:

  • GUID

  • Distinguished name (DN)

  • Name of the mailbox database

  • Server name\storage group name\database name

  • Server name\database name

  • Storage group name\database name

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

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 do not have to specify a value with the Confirm parameter.

DomainController

Optional

Microsoft.Exchange.Data.Fqdn

To specify the fully qualified domain name (FQDN) of the domain controller that retrieves data from Active Directory, include the DomainController parameter in the command.

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 do not have to specify a value with the WhatIf parameter.

Input Types

Return Types

Errors

Error Description

 

Exceptions

Exceptions Description

 

Example

The following example shows how to clean the mailbox database named MyMailboxDatabase.

Clean-MailboxDatabase MyMailboxDatabase