wolfgang ziegler


„make stuff and blog about it“

Getting started with Powershell Script Programming

June 4, 2012

Even though Powershell is an incredibly awesome tool and powerful scripting evironment, your first encounter with it may be a bit cumbersome.

Usually when developing your first Powershell script, saving it as a file and trying to run it, this is what you will get:

<SCRIPTNAME>.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.

Don’t panic! The error message already hints as towards a solution: we have to fiddle with execution policies to enable the execution of (unsigned) Powershell script files.

This sounds more of a big deal than it actually is.

  1. Just open a new Powershell console as an administrator (Shift-Ctrl-Click the existing console in the Windows 7 taskbar or use the context menu). image
  2. Execute the command Set-ExecutionPolicy Unrestricted (tab completion is your friend). image
  3. That’s it! Your good to run your first Powershell script.