Hello Massimo,
We have updated the Reconnect script for you. It will only reconnect mailboxes and not create new if a disconnected mailbox is not found. The script will through an error if a disconnected mailbox with the specified identity is not found.
$exchangeServer = "exchangeserver.domain.com" # TODO: Modify me
$mbGUIDProperty = "adm-CustomAttributeBinary1" # TODO: modify me
$mbStorePathProperty = "adm-CustomAttributeText1" # TODO: modify me
# Get mailbox GUID and Exchange mailbox store DN from Adaxes custom attributes
try
{
$mailboxGuidByte = $Context.TargetObject.Get($mbGUIDProperty)
$mailboxStoreDN = $Context.TargetObject.Get($mbStorePathProperty)
}
catch
{
# No saved information about a disconnected mailbox
return
}
try
{
# Create a remote PowerShell session to the Exchange Server
$session = New-PSSession -connectionURI "http://$exchangeServer/powershell" -ConfigurationName Microsoft.Exchange
Import-PSSession -session $session -DisableNameChecking -AllowClobber
# Reconnect the mailbox
$mailboxGuid = [Guid]$mailboxGuidByte
try
{
Connect-Mailbox -Identity $mailboxGuid -Database $mailboxStoreDN -User "%distinguishedName%" -ErrorAction Stop
}
catch
{
$Context.LogMessage("An error occurred when connecting mailbox. Error: " + $_.Exception.Message, "Error")
return
}
}
finally
{
# Exit remove session, release resources
if ($session) { Remove-PSSession -Session $session }
}
As per our check, it is a known issue in Exchange that even after synchronization the state of a disconnected mailbox is not updated. That is exactly what causes the issue, it is not related to Adaxes or the script used to reconnect mailboxes. To remedy the issue, you need to check Exchange settings.