Enabling ActiveSync for a Security Group using Powershell

$users = Get-ADGroupMember "AD Group with Users to be Enabled for ActiveSync"
foreach ($line in $users) {
    $user = $line.samaccountname
    Set-CASMailbox $user -ActiveSyncEnabled:$true
    Get-CASMailbox $user | Select-Object Name, ActiveSyncEnabled
}