PowerShell script will not start due to execution policy settings

PROBLEM

When you try to execute a PowerShell script the following error occurs:

File C:\scripts\myscript.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see ” get-help about_signing” for more details.

At line:1 char:23

+ c:\scripts\myscript.ps1 <<<<

CAUSE

By default the PowerShell execution policy is set to restricted, which does not allow the PowerShell Scripts to be run. There are 4 possible execution policies in PowerShell:

  • Restricted – the default setting, doesn’t allow any scripts to run.
  • AllSigned – only runs scripts which are signed by a trusted digital certificate
  • RemoteSigned – runs local scripts without requiring them to be trusted. Scripts downloaded from the Internet  must be trusted before they can run.
  • Unrestricted  – allows all scripts to run, even untrusted ones.

SOLUTION:

Use the Set-ExecutionPolicy command to “unlock” you work environment. For example if you are using a lab or learning environment you can issue the following command :

Set-ExecutionPolicy Unrestricted

IMPORTANT: This setting should not be used in a production environment because it could potentially allow scripts downloaded from internet or planted by viruses to be executed.  For a production use AllSigned or eventually Remote Signed policies

http://www.exchangemaster.net/index.php?option=com_content&task=view&id=65&Itemid=57

Enabeling and Disabiling Active Sync for the user

Windows Mobiles can be configured for Active Sync. Active Sync is enabled for all users by Default in Exchange 2007. For Security reasons its recommended to disabled all users and enable only for the required users

Below power shell enabled and disabled Active for all the users in the exchange Organization

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$False

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to enable and disable active sync for given set of users in the text file

Get-content C:\users.txt | set-CASMailbox -ActiveSyncEnabled:$True

Get-content C:\users.txt| set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to get the list of users who ActiveSync is Enabled and Disabled

Get-CASMailbox -ActiveSyncEnabled:$True

Get-CASMailbox -ActiveSyncEnabled:$False