Locate disconnected mailbox in Exchange

Hi

I asked this question here: http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_26953774.html

But just realised that I didn't get the full answer I was looking for! I need to know how to run the commands only on US servers.

>>

Sometimes our support teams accidentally delete the wrong AD account when users leave our company and their mailboxes are set to a 'disconnected' state within our Exchange 2007 environment.

In order to find them again, we need to locate the disconnected mailbox from Exchange. This has two issues:

1. We need to run the 'clean-mailboxdatabase' command to update the names of disconnected mailboxes in a particular db
2. We can only search by each mailbox db in turn

I would like to do the following

a) Run a command that would run clean-mailboxdatabase on all US Exchange servers
b) Run a command that would 'get' all disconnected mailboxes on US Exchange databases

Our Exchange servers are named in the format, region-mbx1, e.g. US-Mbx1, EMEA-Mbx1, APAC-Mbx1.

Does anyone know how I can do this?

Secondly, is there a disadvantage to running clean-mailbox on all databases on a given server at the same time?

>>
neil4933Asked:
Who is Participating?
 
GusGallowsCommented:
I would try the following:
#create an array of all US mailbox servers and then iterate through them one at a time.
$Servers = get-exchangeserver | where {($_.Name -like "US*") -and ($_.IsMailboxServer -eq $true)}
foreach ($Server in $Servers)
{ 
	#get a list of all databases on the selected server and clean them.
	$mdbs = Get-MailboxDatabase -Server $Server
	foreach ($mdb in $mdbs)
	{
		Clean-MailboxDatabase $mdb
	}
	#get a list of all disconnected mailboxes on the selected server.
	Get-MailboxStatistics –Server $Server | Where-Object {$_.DisconnectDate –notlike ‘’}
}

Open in new window

0
 
Exchange_FreakCommented:
I have not tried it but see if you can run the command as Get-ExchangeServer | Get-MailboxDatabase | Clean-Mailboxdatabase
0
 
neil4933Author Commented:
Sure, but I only want to run the Clean Mailbox on US servers?

And do you know how I'd find disconnected mailboxes only on US servers?
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
Exchange_FreakCommented:
Get-Exchangeserver "Names of the US Servers" | Get-MailboxDatabase | Clean-MailboxDatabase
0
 
Chris DentPowerShell DeveloperCommented:
You should be able to see disconnected mailboxes using Get-MailboxStatistics (probably have to target the database name). Sorry I can't give you a specific example right now, won't be at work until Thursday.

Chris
0
 
Shabarinath RamadasanInfrastructure ArchitectCommented:
Even though you dont run the cleanup script, the mailbox will get disconnected in 2 to 3 hours usually.

Here is a nice oneliner to get the disconnected mailboxes using powershell and wmi.

http://exchangeservertips.com/exchange-2010/powershell-script-to-identify-disconnected-mailboxes/

Good luck
Shaba
0
 
Chris DentPowerShell DeveloperCommented:
That'll only work for 2003, not for 2007 / 2010, the WMI interface was introduced (mostly) for 2003, then stripped out again for 2007.

Chris
0
 
GusGallowsCommented:
You can go a step further to make it where you can see which server they are on by adding a few additional lines:
#create an array of all US mailbox servers and then iterate through them one at a time.
$Servers = get-exchangeserver | where {($_.Name -like "US*") -and ($_.IsMailboxServer -eq $true)}
foreach ($Server in $Servers)
{ 
	#get a list of all databases on the selected server and clean them.
	$mdbs = Get-MailboxDatabase -Server $Server
	foreach ($mdb in $mdbs)
	{
		Clean-MailboxDatabase $mdb
	}
	#get a list of all disconnected mailboxes on the selected server.
	$mbs = Get-MailboxStatistics –Server $Server | Where-Object {$_.DisconnectDate –notlike ‘’}
	$server
	$mbs
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.