Hello,
That is exactly what the script should do if a mailbox is properly disconnected. The process should be like the following:
- When you execute the Disconnect mailbox script, it saves the mailbox GUID and the distinguished name (DN) of the mailbox database to the properties specified in the $mbGUIDProperty and $mbStorePathProperty variables accordingly and disconnects the mailbox.
- When you execute the Reconnect mailbox script, it gets the mailbox GUID and the distinguished name (DN) of the mailbox database from the properties and reconnects the mailbox.
A new mailbox is created only if the disconnected mailbox is not found for the user. For example, if you disconnect a mailbox in some other way and the information is not saved to the properties, the Reconnect mailbox script will not be able to find the disconnected mailbox and a new mailbox will be created.
Exchange does not immediately synchronize mailbox state which probably causes the issue. To check whether the mailbox state is synchronized:
- Disconnect a mailbox in Adaxes using the Disconnect mailbox script from our repository.
- Copy the value of the property specified by the $mbStorePathProperty variable.
- Sign in to the computer where Exchange is installed and run PowerShell.
- Execute the following command:
Get-MailboxStatistics -Database <database_store> | where {$_.DisconnectDate -ne $Null}
Where <database_store> is the value you copied on step 2.
Usually, mailboxes are added to the disconnected list once a day. For information on how to synchronize mailbox state, have a look at the following article: https://technet.microsoft.com/en-us/lib ... .150).aspx.