# This is a simple script to search for disconnected mailboxes by display name. It will prompt you to enter a portion of the display name.

##############################################################################################################################
## sean.m.simon 01/03/2013

$in = Read-host “Enter a portion of the display name of the disconnected mailbox you are searching for. (example: Lastname, Firstname)”
Write-Host
Write-Host -ForeGroundColor Green “********* Searching **********”

Get-MailboxDatabase |
Get-MailboxStatistics |
where {($_.DisconnectReason -ne $null) -And ($_.displayname -like “*$in*”)} |
select displayname,LastLoggedOnUserAccount,Identity,database,DisconnectDate,disconnectreason,LastLogonTime,TotalItemSize | fl

Write-Host -ForeGroundColor Green “********* Search Complete **********”
Write-Host
Write-Host ‘The following cmdlet is an example of how to reconnect a mailbox to an existing AD account:’
Write-Host -ForeGroundColor darkcyan ‘Connect-Mailbox -Identity “a3626701-dc92-432a-9cd0-3df34b6f49af” -Database db01 -User firstname.m.lastname’
Write-Host
###############################################################################################################################

