header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Scheduled Task to disable ActiveSync for all EXCEPT some
Last Post 12 Jul 2010 01:50 PM by wildcheese. 3 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
kpeakmanUser is Offline
New Member
New Member
Posts:5
Avatar

--
02 Sep 2009 07:51 AM
    Hi, I am trying to develop a script that will be set to run on a schedule and that will go through Exchange and disable ActiveSync for all users Except the users that are listed on a text file.

    I have seen scripts that will disable AS for all and then go back and re-enable for some that are listed in a text file.. but that is taking the chance that AS will not come back up for those enabled users.. Since most of the AS users that I have are corporate exec's.. I'd rather not take that chance.

    This ps line will show me who is enabled:

    Get-CASMailbox -resultSize unlimited -filter {activeSyncEnabled -eq $true}

    How can I take the results of that command and run another command that disables AS for everyone else not in those results.

    AS by default is enabled for new users that get created.. Would it be easier to find a way to setup AS to be disabled by default for new users?

    Thanks.
    Kenny

    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    03 Sep 2009 12:04 AM
    Add-PSSnapin Microsoft.Exchange*

    $ActiveSyncEnabledUsers = Get-Content ActiveSyncEnabledUsers.txt

    Get-CASMailbox -resultSize unlimited -filter {ActiveSyncEnabled -eq $true} | Foreach-Object {

    if($ActiveSyncEnabledUsers -contains $_.Name)
    {
    $_ | Set-CASMailbox -ActiveSyncEnabled:$true
    }
    else
    {
    $_ | Set-CASMailbox -ActiveSyncEnabled:$false
    }

    }



    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    03 Sep 2009 12:09 AM
    I'm not sure how you can disable AS by default but you can try piping New created mailboxes to Set-CASMailbox and set AS to false.

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    wildcheeseUser is Offline
    New Member
    New Member
    Posts:1
    Avatar

    --
    12 Jul 2010 01:50 PM
    I found it easiest to use Custom Attributes as hooks for my scripts. For example, all my ActiveSync enabled users in my company have Custom Attribute 14 set to ActiveSync. Then I have a daily scheduled script which disables all others.

    get-mailbox -resultsize unlimited | where {$_.customattribute14 -ne "ActiveSync"} | get-casmailbox -resultsize unlimited | where {$_.activesyncenabled -eq $true} | set-casmailbox -activesyncenabled $false

    Voila!! You could easily do this more often and give the appearance that it's automatic...
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer