Script repository
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.