We help IT Professionals succeed at work.

Diasbling active sync for multiple users

tcomp
tcomp asked
on
One of my clients has hundred of users in Active directory and we just setup exchange. How do I do a mass disable of users exchange features to disable activesync by user as we only want to leave a few users with the ability.
Comment
Watch Question

As pulled from http://searchexchange.techtarget.com/tip/0,289483,sid43_gci1355035,00.html (registration required, but free)...

# Adapted from here:
# - http://www.microsoft.com/technet/scriptcenter/csc/scripts/email/exch2007/cscem061.mspx

$SourceFile = "c:\Scripts\DisableActiveSync\users.txt" 
$LogFile = "c:\Scripts\DisableActiveSync\Logs\DisableActiveSyncLog.txt"

$UserList = Get-Content $SourceFile 
foreach($user in $UserList) 
{ 
     $message = "Disabling ActiveSync for user -> " + $user
     write-output $message | out-file -filePath $LogFile -append -noClobber
     Set-CASMailbox -Identity $user -ActiveSyncEnabled $false
     
     if($error.Count -ne 0) 
     { 
           $message = "User " + $user + " ActiveSync settings failed to change ???????????"
           write-output $message | out-file -filePath $LogFile -append -noClobber
           $message = "Error:::: " + $error[0].ToString()
           write-output $message | out-file -filePath $LogFile -append -noClobber
           $error.Clear()
     } 
}

Open in new window

Author

Commented:
That is powershell correct?
Yes indeed!

From my reading of it, it takes the input from the file users and goes down the list.

Author

Commented:
Ive done similar things with VBS alot so it makes sense to me.

Author

Commented:
I ended up just disabling it globally.