Try our new Certificate Revocation List Check Tool
CRLcheck.exe is a tool developed to verify digital signatures of executable files. It collects files from known paths on your client, checks their signature, and checks Certificate Revocation Lists (CRL) and OCSP download. This helps avoid delays in launching files.
Category published:  Exchange 2007 Microsoft Exchange   Click on the Category button to get more articles regarding that product.

Exchange 2007, Powershell, Disable all ActiveSync Options except for users who are member of a Distribution group

Posted by admin on 16.05.2016

Exchange, Powershell, Disable all ActiveSync Options except for users who are member of a Distribution group

 
 

# Activesync Robot Script for Exchange # Exchange 2007 (2010 has) does not have the option to disable new added activesync partners automatic.
# —————————————————————————————————–
# M.Butsch
# 1) Disables all Activesync Options for ALL new User
# 2) Enables Activesync for all users who are member of the Distribution group “activesync”


#Prueft ob die Snap Ins schon geladen sind und skipt diese falls schon vorhanden (Änderung/Butsch/13.12.2012)

If (@(Get-PSSnapin -Registered | Where-Object {$_.Name -eq “Microsoft.Exchange.Management.PowerShell.E2010”} ).count -eq 1)
 {
     If (@(Get-PSSnapin | Where-Object {$_.Name -eq “Microsoft.Exchange.Management.PowerShell.E2010”} ).count -eq 0)
  {
         Write-Host “Loading Exchange Snapin Please Wait….”
  Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
  }
        }

#Load Exchange PS Snapin
If (@(Get-PSSnapin -Registered | Where-Object {$_.Name -eq “Microsoft.Exchange.Management.PowerShell.Admin”} ).count -eq 1)
 {
 If (@(Get-PSSnapin | Where-Object {$_.Name -eq “Microsoft.Exchange.Management.PowerShell.Admin”} ).count -eq 0)
  {
         Write-Host “Loading Exchange Snapin Please Wait….”
  Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
  }
        }

# Disable ActiveSync
get-Mailbox -ResultSize:unlimited | set-CASMailbox -ActiveSyncEnabled:$False -ErrorAction SilentlyContinue -WarningAction SilentlyContinue

# Assign all members of the group to a dynamic array
$allUsers = Get-DistributionGroupMember -Identity ‘activesync’

# Loop through the array
foreach ($member in $allUsers) {

# Set ActiveSync for each member of the array
$member | Set-CASMailbox –ActiveSyncEnabled $true
}

   
 

How to make this work on a Exchange 2007 Server:

1) Copy the File to c:\batch\activesync.ps1

2) Create a LINK on the Desktop

TARGET: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile exshell.psc1 -noexit -command “& {c:\batch\activesync.ps1}”

RUNIN: “C:\Program Files\Microsoft\Exchange Server\Bin”

You also MAY have to edit the Powershell RUn POLICY > Please be carefull what you do. With this command you can run all PS1 scripts and also virus if you ever have.

Set-ExecutionPolicy Unrestricted

http://technet.microsoft.com/en-us/library/ee176961.aspx 

Changing the Windows PowerShell Script Execution Policy

The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies:

  • Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
  • AllSigned – Only scripts signed by a trusted publisher can be run.
  • RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
  • Unrestricted – No restrictions; all Windows PowerShell scripts can be run.

 Category published:  Exchange 2007 Microsoft Exchange   Click on the Category button to get more articles regarding that product.