Export mailbox from Exchange 2010

Start Exchange Management Shell

If you want to export a user mailbox from exchange to a .pst file:
New-MailboxExportRequest -Mailbox daniel.andersson -FilePath \\exchange2010\export\daniel.andersson.pst

To see the status of the export:
Get-MailboxExportRequest -Name MailboxExport | fl

To see completed mailbox export requests:
Get-MailboxExportRequest | where {$_.status -eq “Completed”}

To clear all completed mailbox export request:
Get-MailboxExportRequest | where {$_.status -eq “Completed”} | Remove-MailboxExportRequest

Add permission on all public folders in Exchange

I used this to get folder owner permissions on all public folders for the user daniel.

In Exchange Management Console:
Get-PublicFolder -recurse | Add-PublicFolderClientPermission -User daniel -AccessRights FolderOwner
Get-PublicFolder -recurse | Add-PublicFolderAdministrativePermission -User daniel -AccessRights AllExtendedRights

Search for an email address in Exchange / Active Directory

Open Active Directory Users and Computers. Right click on the domain and choose find. Change to custom search in the find field. Click on the advanced tab to enter a LDAP query.

LDAP query to find the email address daniel@domain.com:
proxyAddresses=smtp:daniel@domain.com

LDAP query to find all objects that uses the email domain domain.com:
proxyAddresses=smtp:*@domain.com

Removing disconnected mailboxes in Exchange 2010

List mailbox databases guid
> Get-MailboxDatabase |ft Name, Guid

List disconnected mailboxes in a specific database
> Get-MailboxStatistics -Database <database guid> | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL DisplayName, DisconnectDate, MailboxGuid

Delete a specific disconnected mailbox
> Remove-Mailbox -Database “<databasename>” -StoreMailboxIdentity <mailbox guid> -confirm:$false

Delete all disconnected mailboxes in a specific database
> $users = Get-MailboxStatistics -Database “<databasename>” | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database

> $users | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }

Example
Delete a specific disconnected mailbox in the database named My Database
> Remove-Mailbox -Database “My Database” -StoreMailboxIdentity g437dd12-2f96-4a67-8f6f-c47fa70247e2 -confirm:$false

Delete all disconnected mailboxes in the database named My Database
> $users = Get-MailboxStatistics -Database “My Database” | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database

> $users | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }

EMC error: An error caused a change in the current set of domain controllers.

When opening Exchange Manangemnt Console you get the following error:
An error caused a change in the current set of domain controllers. It was running the command ‘Get-OrganizationConfig’.

In the application log you get the following error entries:
Event ID: 4
Source: MSExchange Configuration Cmdlet – Remote Mamagment
General: Task Get-ExchangeServer writing error when processing record of index 0. Error: Microsoft.Exchange.Data.Directory.SuitabilityDirectoryException: An Active Directory error 0x51 occurred when trying to check the suitability of server ‘dc.mydomain.com’. Error: ‘Active directory response: The LDAP server is unavailable.’ —>

Event ID: 5
Source: MSExchange Configuration Cmdlet – Remote Mamagment
General: Task Get-ExchangeServer throwing terminating exception at stage Microsoft.Exchange.Data.Directory.ADTransientException: An error caused a change in the current set of domain controllers..

This happend to me after a domain controller was removed and replaces with a new one on the same site as the Exchange 2010 server.

To solve this problem close the EMC. Delete the file  C:\Users\%username%\AppData\Roaming\Microsoft\MMC\Exchange Management Console. Open EMC again and you shold not get the error message again.