Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Exchange Server
Scheduled Task to disable ActiveSync for all EXCEPT some
Last Post 12 Jul 2010 01:50 PM by
wildcheese
. 3 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
kpeakman
New Member
Posts:5
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 Levy
PowerShell MVP, Admin
Veteran Member
Posts:1362
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 Levy
PowerShell MVP, Admin
Veteran Member
Posts:1362
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
wildcheese
New Member
Posts:1
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.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Exchange Server
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2