I have created a small powershell script to disable active sync for mailboxes when the user is not a member of a specific AD group. This script works perfectly when running it from my Windows 7 workstation from the Exchange Management Shell. It does not however work on the CAS server's EMS.
$groupname = "ActiveSync Users"
$groupidentity = $(Get-Group $groupname).Identity.DistinguishedName
Get-Mailbox -ResultSize unlimited |Set-CASMailbox -ActiveSyncEnabled $false -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
$users = Get-ADGroupMember $groupname | select -ExpandProperty name
foreach ($user in $users) {
Get-Mailbox $user | Set-CASMailbox -ActiveSyncEnabled $true
}
Both the Get-Mailbox | Set-CASMailbox
and the Get-ADGroupMember
parts of the code fail on the Exchange CAS server. The Get-Mailbox | Set-CASMailbox
lists warnings that no settings have been modified for every user account. The Get-ADGroupMember
is erroring as a non recognized cmdlet.
It looks like either a permissions error or some dependancy is missing from the Exchange server, but I'm unsure of where to look to see what is missing.