Configure enabling and disabling remote mailboxes

By default, if an Exchange organization operates in hybrid mode, Adaxes automatically enables and disables remote mailboxes when a Microsoft 365 license with access to Exchange Online is assigned or revoked. The remote routing address for remote mailboxes is generated by Exchange. You can disable the feature, configure Adaxes to enable and disable remote mailboxes even if an Exchange organization is not in hybrid mode and specify your own template for generation of the remote routing addresses. The settings are separately configured for each Microsoft 365 tenant registered in Adaxes.

Only Adaxes service administrators have the rights to configure the settings for enabling and disabling remote mailboxes.

Change when remote mailboxes are enabled and disabled

To specify when remote mailboxes should be automatically enabled and disabled, execute the below script in Windows PowerShell. In the script:

  • $serviceHost – the host name of the computer where Adaxes service is installed.

  • $tenantDN – the distinguished name of the Microsoft 365 tenant to change settings for.

     How to get the tenant distinguished name
    1. Launch Adaxes Administration console.

    2. In the Console Tree, expand the Adaxes service node (the icon represents service nodes).

    3. Navigate to Configuration \ Cloud Services.

    4. Click Microsoft 365.

    5. In the Managed Microsoft 365 tenants section on the right, right-click a tenant and then click Properties in the context menu.

    6. In the dialog that opens, click Advanced.

    7. Tenant distinguished name will be displayed next to the Object DN label.

  • $enableRemoteMailboxSetting – the desired behavior for enabling remote mailboxes. Possible values:

    • $null (default behavior) – remote mailboxes will be enabled only if Exchange organization operates in hybrid mode.
    • $false – remote mailboxes will never be enabled.
    • $true – remote mailboxes will be enabled even if Exchange organization does not operate in hybrid mode.
  • $disableRemoteMailboxSetting – the desired behavior for disabling remote mailboxes. Possible values:

    • $null (default behavior) – remote mailboxes will be disabled only if Exchange organization operates in hybrid mode.
    • $false – remote mailboxes will never be disabled.
    • $true – remote mailboxes will be disabled even if Exchange organization does not operate in hybrid mode.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost"
$tenantDN = <TENANT DN>
$enableRemoteMailboxSetting = $true
$disableRemoteMailboxSetting = $true

# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly($serviceHost)

# Prompt for credentials.
$credential = Get-Credential

# Bind to the Microsoft 365 tenant.
$tenant = $service.OpenObject("Adaxes://$tenantDN", `
    $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Update the settings.
$tenant.EnableRemoteMailboxes = $enableRemoteMailboxSetting
$tenant.DisableRemoteMailboxes = $disableRemoteMailboxSetting
$tenant.SetInfo()

Change remote routing address template

To specify your own remote routing address template for enabling remote mailboxes, execute the below script in Windows PowerShell. In the script:

  • $serviceHost – the host name of the computer where Adaxes service is installed.

  • $tenantDN – the distinguished name of the Microsoft 365 tenant to change settings for.

     How to get the tenant distinguished name
    1. Launch Adaxes Administration console.

    2. In the Console Tree, expand the Adaxes service node (the icon represents service nodes).

    3. Navigate to Configuration \ Cloud Services.

    4. Click Microsoft 365.

    5. In the Managed Microsoft 365 tenants section on the right, right-click a tenant and then click Properties in the context menu.

    6. In the dialog that opens, click Advanced.

    7. Tenant distinguished name will be displayed next to the Object DN label.

  • $addressTemplate – the remote routing address template to be set. You can use value references in the template (e.g. %firstname%.%lastname%@company.mail.onmicrosoft.com). Value references will be replaced with the corresponding property values of the user account for which a remote mailbox is enabled.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost"
$tenantDN = <TENANT DN>
$addressTemplate = "%firstname%.%lastname%@company.mail.onmicrosoft.com"

# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly($serviceHost)

# Prompt for credentials.
$credential = Get-Credential

# Bind to the Microsoft 365 tenant.
$tenant = $service.OpenObject("Adaxes://$tenantDN", `
    $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Update the template.
$tenant.RemoteMailboxesRemoteRoutingAddress = $addressTemplate
$tenant.SetInfo()

View current settings

To view current settings for enabling and disabling remote mailboxes, execute the below script in Windows PowerShell. In the script:

  • $serviceHost – the host name of the computer where Adaxes service is installed.

  • $tenantDN – the distinguished name of the Microsoft 365 tenant to change settings for.

     How to get the tenant distinguished name
    1. Launch Adaxes Administration console.

    2. In the Console Tree, expand the Adaxes service node (the icon represents service nodes).

    3. Navigate to Configuration \ Cloud Services.

    4. Click Microsoft 365.

    5. In the Managed Microsoft 365 tenants section on the right, right-click a tenant and then click Properties in the context menu.

    6. In the dialog that opens, click Advanced.

    7. Tenant distinguished name will be displayed next to the Object DN label.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost"
$tenantDN = <TENANT DN>

# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly($serviceHost)

# Prompt for credentials.
$credential = Get-Credential

# Bind to the Microsoft 365 tenant.
$tenant = $service.OpenObject("Adaxes://$tenantDN", `
    $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Settings for enabling remote mailboxes
$result = "Enable remote mailboxes: "
switch ($tenant.EnableRemoteMailboxes)
{
    $true
    {
      $result += "Always"
    }
    $false
    {
      $result += "Never"
    }
    default
    {
      $result += "Only if the Exchange organization operates in hybrid mode"
    }
}

# Settings for disabling remote mailboxes
$result += "`r`nDisable remote mailboxes: "
switch ($tenant.DisableRemoteMailboxes)
{
    $true
    {
      $result += "Always"
    }
    $false
    {
      $result += "Never"
    }
    default
    {
      $result += "Only if the Exchange organization operates in hybrid mode"
    }
}

# Remote routing address template
$result += "`r`nRemote routing address template: "
if ($tenant.RemoteMailboxesRemoteRoutingAddress -eq $null)
{
    $result += "<The address is generated by Exchange>"
}
else
{
    $result += $tenant.RemoteMailboxesRemoteRoutingAddress
}

Write-Host $result