The Shonk Project
Home arrow Scripts arrow Running PowerShell Scripts Out of the Box
Wednesday, 08 September 2010
Main Menu
Home
News
Blogs
Scripts
Contact Us


Syndicate
Running PowerShell Scripts Out of the Box PDF Print
Written by Joe Shonk   
Monday, 21 April 2008

By default,  Microsoft disables the ability to execute PowerShell scripts out of the box.  Normally, one would need to manually change this policy to 'Unrestricted' before he or she is able to run scripts.

The PowerShell Syntax for seting the Execution Policy to Unrestricted is:

PS > Set-ExecutionPolicy Unrestricted

To set the Policy back to Restricted:

PS > Set-ExecutionPolicy Restricted

To query the status of the Execution Policy:

PS > Get-ExecutionPolicy

Setting the policy manually can be disconcerning for those who automate their installation scripts and would like to start incorporating PowerShell scripts as part of that framework.  So now you have the .Net Framework and the PowerShell install automated, but now manual intervention is required before you can start running your PowerShell scripts.  Bum.  But wait!  There is a way to automatically set the Execution Policy.

The Execuction Policy is stored in the registry at this location:

 Registry Key  Registry Value  
 HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
 ExecutionPolicy

 Data   Default  
 Restricted Yes
 Unrestricted 
 

Changes to this registry value is immediate.  Even if a PowerShell console is currently opened.  So by including something like a REG.EXE (from the Windows 2003 Resource Kite) statement in your PowerShell installation script, you can unlock the power of your PowerShell Scripts.

Comments
Add New RSS
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
< Prev   Next >