Disconnected mailboxes and disconnected date

To display mailboxes that are disconnected use the following command.
Replace with the name of your mailbox server.
This gives a list of the disconnected mailboxes.
Get-MailboxStatistics -Server | where { $_.DisconnectDate -ne $null } | select DisplayName,DisconnectDate

To reconnect you use the command below
Connect-mailbox –database "mailbox database name" –Identity "disconnected mailbox name" –User "User to connect to"

Run Cleanup agent in Exchange 2007

After the deletion of a user with an mailbox this mailbox is left on the mailserver as an “disconnected mailbox”.

The process can take some time but can be started manual.

Start the “Exchange Management Shell”

Clean-MailboxDatabase “Your_Mailbox_Database_Name”

Exchange 2010: Which mailbox is linked to a specific email address?

If you want to find a email address that is used in the organisation but you don’t know the mailbox it is linked to.
This works for aliases to.

[PS] C:\Windows\system32>Get-Recipient random.email@company.com

Name                                                                    RecipientType
—-                                                                          ————-
Test User                                                              UserMailbox

 

Export all your Exchange email addresses to CSV

To create a list of all your email addresses including the primary and alias addresses run this PowerShell command;

Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV c:\smtp.csv -NoTypeInformation

Handy Exchange Management Shell commands

Some Handy Exchange Management Shell commands I frequently use;

  • Enable auditing for all user mailboxes
    Get-Mailbox | Where-Object {$_.RecipientTypeDetails –eq “UserMailbox”} |Set-Mailbox -AuditDelegate Update,SoftDelete,HardDelete,SendAs,Create,FolderBind –Auditenabled $true
  • Get a list of all mailboxes on a Exchange server sorted on size.
    Get-MailboxStatistics -Server SERVERNAME | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto >>C:\Mailboxsize.txt
  • Delete disconnected mailboxes
    $mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database

    $mailboxes | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }
  • Import PST file into a mailbox into a root folder “Archive”
    New-MailboxImportRequest -FilePath \\uncshare\archive.pst -Mailbox MAILBOXNAME -TargetRootFolder "Archive"