Script repository

Synchronize allowed ActiveSync devices to Exchange Online

Updated on: Jan 18, 2026, Views: 3609

Exchange

The script synchronizes the list of allowed ActiveSync devices of a user from on-premises Active Directory to their Exchange Online mailbox. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.

# Get Microsoft 365 object ID
try
{
    $objectId = [Guid]$Context.TargetObject.Get("adm-AzureId")
}
catch
{
    return
}

# Get device IDs.
try
{
    $deviceIDs = $Context.TargetObject.GetEx("msExchMobileAllowedDeviceIDs")
}
catch
{
    $deviceIDs = $NULL
}

# Connect to Exchange Online.
$Context.CloudServices.ConnectExchangeOnline()

# Set devices
Set-CASMailbox -Identity $objectId.ToString() -ActiveSyncAllowedDeviceIDs $deviceIDs

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.