Remove-Mailbox doesn't work because MailboxGuid exists twice *SOLVED*
Hello everyone,
I have a problem on our Exchange Server 2007. I have a user with a mailbox which can't be accessed by Outlook, only by webmail.This same user has a mailbox in the Disconnected Mailboxes. Both mailboxes are on a different Database, but have the same MailboxGuid.What I can see is that the ItemCount is different, the mailbox in use has 7100 items, the disconnected has only 2 item.So I filter that mailbox by using:
Code Snippet$temp = Get-MailboxStatistics | Where {$_.DisplayName -eq "Username"} | Where {$_.ItemCount -eq '2'} | Select DisplayName,ItemCount,Database,MailboxGuid
Result:
Code Snippet
DisplayName ItemCount Database MailboxGuid
Username7100Mailbox Database 4abcd1234
Username2Mailbox Database 1 abcd1234
After that I typed in:
Code SnippetRemove-Mailbox -Database $temp.Database -StoreMailboxIdentidy $temp.MailboxGuid
But this resolves in an error:
Code Snippet
Remove-Mailbox : The mailbox that you specified is connected to "Username". Only disconnected mailboxes can be reconnected. Specified mailbox: "abcd1234".At line:1 char:15
Does someone know how I can remove the disconnected mailbox but keep the one in use?
Thank you very much for any help!!Sebastiaan.
September 23rd, 2008 11:19am
Hi Sebastiaan,
GUID should be unique for all mailboxes.
Are you able to see disconnected mailbox in Recipient Configuration -> Disconnected Mailbox? If not, then run below command on the database where mailbox was residing.
Clean-MailboxDatabase Mailbox Database 1
Once you see the disconnected mailbox, can you try below command and see the result?
Code Snippet$temp = Get-MailboxStatistics | Where {$_.DisplayName -eq "Username" -and $_.ItemCount -eq 2}$temp | select displayname, mailboxguidRemove-Mailbox -Database $temp.Database -StoreMailboxIdentidy $temp.MailboxGuid
Free Windows Admin Tool Kit Click here and download it now
September 23rd, 2008 11:45am
Thank for your quick reply!I can see the mailbox in Receipient Configuration -> Disconnected MailboxRunning the code you wrote displays this information:
Code Snippet
DisplayNameMailboxGuid
Username e2931df6-4996-4884-8c68-0daf8394b64d
But, running the code without the "-and $_.ItemCount -eq 2" shows:
Code Snippet
DisplayName MailboxGuid
Usernamee2931df6-4996-4884-8c68-0daf8394b64d
Username e2931df6-4996-4884-8c68-0daf8394b64d
As you can see, both the same MailboxGuid
September 23rd, 2008 11:58am
Clarify: EMS cannot remove disconnected mailbox as it shares same MailboxGuid with new one
Since both disconnected and current mailboxes share the same MailboxGuid, server will fail to execute the command
Therere two ways to remove disconnected mailbox:
1. Wait for Deleted mailbox cleanup running to purge it
2. Please try Amits remove command at first. As we can see, with itemCount -eq 2, its already filtered that disconnected mailbox out, not like the command in your first post, it filtered both disconnected and current mailboxes
3. If its still not working, please try the following cmdlet:
Get-MailboxStatistics -database "SERVERNAME\STORAGEGROUP\DATABASE" | where {$_.disconnectdate -ne $null -and $_.displayname -contains 'UserDisplayName'} | foreach {remove-mailbox -database "SERVERNAME\STORAGEGROUP\DATABASE" -storemailboxidentity $_.mailboxguid}
Notes: To be sure we get the right data; we can run the following first:
Get-MailboxStatistics -database "SERVERNAME\STORAGEGROUP\DATABASE" | where
{$_.disconnectdate -ne $null -and $_.displayname -contains 'UserDisplayName'}
Resources:
Remove-Mailbox
How to remove disconnected mailboxes in Exchange Server 2007
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2008 3:53am
Hi James,
thanks for you reply.I tried Amit's remove command again, but that didn't work.Cleanup should have run a long time ago I guess, because the user can't use outlook for a long time now (arround 2 months). So than the mailbox should have been deleted already.I tried your 3rd solution, but that also didn't work Below is the script I run with all information, I hope this is usefull.
Code Snippet
[PS] >Clean-MailboxDatabase "Mailbox Database 1"
[PS] >$temp = Get-MailboxStatistics | Where {$_.DisplayName -eq "Username" -and $_.ItemCount -eq 2}[PS] >$temp
DisplayNameItemCountStorageLimitStatus LastLogonTime-------------------- ------------------ -------------Username2 8/28/2008 2:42:46 PM
[PS] >$temp | select displayname,mailboxguid
DisplayNameMailboxGuid----------------------Usernamee2931df6-4996-4884-8c68-0daf8394b64d
[PS] >Remove-Mailbox -Database $temp.Database -StoreMailboxIdentidy $temp.MailboxGuidRemove-Mailbox : A parameter cannot be found that matches parameter name 'StoreMailboxIdentidy'.At line:1 char:62+ Remove-Mailbox -Database $temp.Database -StoreMailboxIdentidy <<<< $temp.MailboxGuid
[PS] >$temp.MailboxGuid Running this command returns a empty row
[PS] >$temp.DisplayNameUsername
[PS] >Get-MailboxStatistics -database "EXCHANGE\First Storage Group\Mailbox Database 1" | where {$_.disconnectdate -ne $null -and $_.displayname -contains "Username"}
DisplayNameItemCountStorageLimitStatus LastLogonTime-------------------- ------------------ -------------Username2 8/28/2008 2:42:46 PM
[PS] >Get-MailboxStatistics -database "EXCHANGE\First Storage Group\Mailbox Database 1" | where {$_.disconnectdate -ne$null -and $_.displayname -contains "Username"} | foreach {remove-mailbox -database "EXCHANGE\First Storage Group\Mailbox Database 1" -storemailboxidentity $_.mailboxguid}Remove-Mailbox : The mailbox that you specified is connected to "Username".
Only disconnected mailboxes can be reconnected.
Specified mailbox: "e2931df6-4996-4884-8c68-0daf8394b64d".At line:1 char:187+ Get-MailboxStatistics -database "EXCHANGE\First Storage Group\Mailbox Database 1" | where {$_.disconnectdate -ne $null -and $_.displayname -contains "Username"} | foreach {remove-mailbox <<<< -database "EXCHANGE\First Storage Group\Mailbox Database 1" -storemailboxidentity $_.mailboxguid}
September 24th, 2008 10:26am
1. Set Keep deleted mailbox to 0 against the disconnected mailboxs store in the EMC
2. Run Clean-MailboxDatabase against both stores, it can scan the disconnected mailbox that is not yet marked as disconnected in the store
3. After that, go to EMC, check the disconnected mailbox list. If the disconnected mailbox is still there, try to cmdlet to remove again
4. If above steps is still not working, try the following
5. Backup current mailbox to PST by using Export-Mailbox
6. Disable current mailbox in the EMC, run Clean-MailboxDatabase against both stores
7. Check disconnected mailbox check by cmdlet, see if old mailbox has gone, if yes, reconnect current one back
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2008 11:06am
Thank you James,I did step 1 and 2 and the mailbox was gone! Problem solved for now Thanks all.
September 26th, 2008 11:58am
After an accidental Active Directory OUdeletion and apartially successfulrestore we were left with thousands of duplicate GUIDs, and got this same error when we tried toremove thedisconnected mailboxes. Thanks James for your comments. We ran steps 1 and 2 and they were all cleaned up.Joe
Free Windows Admin Tool Kit Click here and download it now
August 31st, 2009 10:03pm