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.

Script repository

Synchronize allowed ActiveSync devices to Exchange Online

May 08, 2023 Views: 2474

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

Edit Remove
PowerShell
# Get Microsoft 365 object ID
try
{
    $objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
    return # No Microsoft 365 account
}

# 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
Leave a comment
Loading...

Got questions?

Support Questions & Answers