Our tech tip this week will help you in the process to enable/disable ActiveSync in Powershell by CSV, Single User and Attribute.

Some organizations require for some users or vendors not to have ActiveSync enabled. Below are scripts on how to disable/enable ActiveSync by CSV, Attribute-based and by a single user. Disabling ActiveSync for users can also be done through Exchange Admin Center.

Additional Sources:

https://support.microsoft.com/en-us/help/2795303/how-to-disable-exchange-activesync-for-users-in-office-365

Instructions:

Connect to Exchange Online using the Windows Azure Powershell Module

Enable ActiveSync For A Single User:

Set-CASMailbox -Identity [email protected] -ActiveSyncEnabled $True

Disable ActiveSync For A Single User: 

Set-CASMailbox -Identity [email protected] -ActiveSyncEnabled $False

Disable ActiveSync For A Group Of Users With AD Attribute Department Matching “Vendor”

Get-User -RecipientTypeDetailsUserMailbox | where {$_.Department -eq “Vendor”} | Set-CASMailbox -ActiveSyncEnabled $False

Enable ActiveSync For A Group Of Users With AD Attribute Department Matching “Vendor”

Get-User -RecipientTypeDetailsUserMailbox | where {$_.Department -eq “Vendor”} | Set-CASMailbox -ActiveSyncEnabled $True

Disable ActiveSync By CSV:

Instructions:

  1. Create a CSV file name the top Column Users and under that column specify the users.
  2. Update the CSV path for the import and update the Log File path.

Script:

Import-CSV “C:\temp\ActiveSYNC.csv” | foreach {Set-CASMailbox -Identity $_.User -ActiveSyncEnabled $False} 2>> “c:\temp\Active-Sync-Disable-Logs.txt”

Screen Shot Example Of CSV:

screenshot example csv

Enable ActiveSync By CSV:

Instructions:

  1. Create a CSV file name the top Column Users and under that column specify the users.
  2. Update the CSV path for the import and update the Log File path.

Script:

Import-CSV “C:\temp\ActiveSYNC.csv” | foreach {Set-CASMailbox -Identity $_.User -ActiveSyncEnabled $True} 2>> “c:\temp\Active-Sync-Enable-Logs.txt”

Was this article helpful?
YesNo