how to enable activesync for users in a specail group in Exhcange 2007

beardog1113
beardog1113 used Ask the Experts™
on
hello Expert
my question is simple, as title, i want to enable activesync feature for users, and they are in a special group, i want to know which command i should use, so that i do not necessary enable them one by one.

thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Is special group mean specific organization? if yes try this:

Get-Mailbox -ResultSize Unlimited | where {$_.OrganizationalUnit -eq "domain.com/OU1"} | Set-CASMailbox -Identity $_ -ActiveSyncEnabled:$True

Open in new window

Author

Commented:
hello
the group i mentioned is a distribute group in Active Directory, not OU.

any suggestion?

thank you
You are going to have to use a combination of Active Directory Powershell commands and Exchange Powershell commands.

You will have to enable the Active Directory Power shell commands on a server that also has the Exchange management shell installed.

Start up powershell by right clicking the icon and selected import system modules

Now you should be able to query the group and set it to a variable
$users = Get-ADGroupMember -Id "<Group Name>"

Use a for loop to set the CASMailbox attribute
foreach ($i in $users) {Set-CASMailbox -id $i.Name -ActiveSyncEnabled $true}

(we use $i.Name because the Set-CASMailbox command doesn't accept the default value of the Get-ADGroupMember cmdlet)

For Distribution groups you can skip the Active Directory module and just use Exchange Shell
Get-DistributionGroup -ID "<Group Name>" | Set-CASMailbox -ActiveSyncEnabled $true
You can also use only Exchange Management Shell to the work:

$Users = Get-DistributionGroupMember -Identity <Groupname>

foreach ( $User in $Users ) {

Set-CASMailbox -Identity $User.Displayname -ActiveSyncEnabled:$true -WhatIf

}

Open in new window


Try this code on your enviroment, if it is working, then remove the -WhatIf command

Author

Commented:
hello
i got the following error after promote this command:

Unexpected token 'in' in expression or statement.
At line:1 char:91
+ $Users = Get-DistributionGroupMember -Identity "AP\AP Activesync users" foreach ( $User in  <<<< $Users ) {Set-CASMailbox -Identity $User.Displayname -Acti
SyncEnabled:$true -WhatIf}

thanks
This should work...

get-DistributionGroupMember -ID <GroupName> | Set-CASMailbox -ActiveSyncEnabled $true

The command that beardog provided should work also, just have to make sure the foreach command is ran on a seperate line

$Users = Get-DistributionGroupMember -Identity "AP\AP Activesync users"

foreach ( $User in $Users ) {Set-CASMailbox -Identity $User.Displayname -ActiSyncEnabled:$true -WhatIf}


I incorrectly listed get-DistributionGroup rather than Get-DistributionGroupMember in my previous post.

Author

Commented:
hello expert
i still got the error

[PS] C:\Documents and Settings\bin.zhangadm>$Users = Get-DistributionGroupMember -Identity "AP\AP Activesync users" foreach ($User in $Users) {Set-CASMailbox -I
dentity $User.Displayname -ActiveSyncEnabled:$true}
Unexpected token 'in' in expression or statement.
At line:1 char:90
+ $Users = Get-DistributionGroupMember -Identity "AP\AP Activesync users" foreach ($User in  <<<< $Users) {Set-CASMailbox -Identity $User.Displayname -ActiveSy
ncEnabled:$true}

something like "in" parameter is not correct.

thank you
Use the one I posted

Author

Commented:
hello expert
which one you mean? this one?
[PS] C:\Documents and Settings\bin.zhangadm>Get-DistributionGroupMember -Identity "ap\ap activesync users" | Set-CASMailbox -ActiveSyncMailboxPolicy $true
Set-CASMailbox : Cannot bind parameter 'ActiveSyncMailboxPolicy'. Cannot convert value "True" to type "Microsoft.Exchange.Configuration.Tasks.MailboxPolicyIdPa
rameter". Error: "Invalid cast from 'System.Boolean' to 'Microsoft.Exchange.Configuration.Tasks.MailboxPolicyIdParameter'."
At line:1 char:105
+ Get-DistributionGroupMember -Identity "ap\ap activesync users" | Set-CASMailbox -ActiveSyncMailboxPolicy  <<<< $true


thanks
Yea but the second part is -activesyncenabled $true

Author

Commented:
sorry for mistake, it works now.

thank you very much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial