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 enabling 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.

Note

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, use the below script. In the script:

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

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

     How to get the tenant 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 and select Microsoft 365.
    4. Registered Microsoft 365 tenants and their names will be displayed on the right.
  • $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"
$tenantName = "My tenant"
$enableRemoteMailboxSetting = $True
$disableRemoteMailboxSetting = $True

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

# Prompt for credentials.
$credential = Get-Credential

# Bind to the Microsoft 365 tenant.
$configurationContainerPath = 
    $admService.Backend.GetConfigurationContainerPath("CloudServicesO365")
$configurationContainer = $admService.OpenObject($configurationContainerPath, `
    $credential.UserName, $credential.GetNetworkCredential().Password, 0)
$tenant = $configurationContainer.GetObject("adm-O365Tenant", "CN=$tenantName")

# 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, use the below script. In the script:

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

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

     How to get the tenant 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 and select Microsoft 365.
    4. Registered Microsoft 365 tenants and their names will be displayed on the right.
  • $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"
$tenantName = "My tenant"
$addressTemplate = "%firstname%.%lastname%@company.mail.onmicrosoft.com"

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

# Prompt for credentials.
$credential = Get-Credential

# Bind to the Microsoft 365 tenant.
$configurationContainerPath = 
      $admService.Backend.GetConfigurationContainerPath("CloudServicesO365")
$configurationContainer = $admService.OpenObject($configurationContainerPath, `
    $credential.UserName, $credential.GetNetworkCredential().Password, 0)
$tenant = $configurationContainer.GetObject("adm-O365Tenant", "CN=$tenantName")

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

View current settings

To view current settings for enabling and disabling remote mailboxes, use the below script. In the script:

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

  • $tenantName – the name of the Microsoft 365 tenant to output settings for.

     How to get the tenant 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 and select Microsoft 365.
    4. Registered Microsoft 365 tenants and their names will be displayed on the right.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost"
$tenantName = "My tenant"

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

# Prompt for credentials.
$credential = Get-Credential

# Bind to the Microsoft 365 tenant.
$configurationContainerPath = 
      $admService.Backend.GetConfigurationContainerPath("CloudServicesO365")
$configurationContainer = $admService.OpenObject($configurationContainerPath, `
    $credential.UserName, $credential.GetNetworkCredential().Password, 0)
$tenant = $configurationContainer.GetObject("adm-O365Tenant", "CN=$tenantName")

# 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