Friday, 24 July 2015

Enable ActiveSync for Mailbox Users using Powershell

We can enable and disable Exchange ActiveSync feature for mailbox users using the powershell cmdlet Set-CASMailbox. This article contains Powershell scirpt to enable ActiveSync feature for a single user and set of users.

Before proceed, run the following command to enable Exchange cmdlets if you are working with Powershell console instead of Exchange Management Shell.
Add-PSSnapin *Exchange*

Enable Exchange ActiveSync for a Single User:

Run the following command to enable Exchange ActiveSync for a single user:
Set-CASMailbox -Identity "Morgan" -ActiveSyncEnabled $True
Use the below command and check the ActiveSync feature is enabled for the corresponding user which you have used in the above command.
Get-CASMailbox -ResultSize Unlimited

Enable ActiveSync Feature for a Group of Users:

We can use the Active Directory powershell cmdlet Get-ADUser to get a group of users and pass the selected users to Set-CASMailbox cmdlet to enable Exchange ActiveSync feature. We can set target OU and apply filter in Get-ADUser cmdlet to get specific set of users. Before proceed, run the following command to import Active Directory powershell cmdlets.
Import-Module ActiveDirectory
The following powershell command select and enable ActiveSync feature for all the users from the container TestOU.
$users = Get-ADUser -Filter * -SearchBase "OU=TestOU,DC=TestDomain,DC=com";
$users | ForEach-Object {
Set-CASMailbox -Identity $_.Name -ActiveSyncEnabled $True
}
You can also apply Filter to select particular set of users, the following command select and enable Exchange ActiveSync feature for all the users who are under Testing department.
$users = Get-ADUser -Filter 'Department -like "*Testing*"';
$users | ForEach-Object {
Set-CASMailbox -Identity $_.Name -ActiveSyncEnabled $True
}
Instead of SQL like fiter, you can use ldap filter by using the parameter -LDAPFilter.
$users = Get-ADUser -LDAPFilter '(Department=*Testing*)';
$users | ForEach-Object {
Set-CASMailbox -Identity $_.Name -ActiveSyncEnabled $True
}

Enable ActiveSync Feature for Multiple Users:

Use the below powershell script to enable Exchange ActiveSync connectivity for a set of mailbox users. Give the set of user names as string Array.
$users = "usr1","usr2","usr3","usr4"
Foreach($user in $users) {
Set-CASMailbox -Identity $user -ActiveSyncEnabled $True
}

Advertisements
Advertisements

No comments:

Post a Comment