Tome's Land of IT

IT Notes from the Powertoe – Tome Tanasovski

Powershell ISE

I thought I would divert from my beginner tutorial to share a built-in tool from Microsoft to help with development of Powershell scripts.  Run “powershell_ise“.

It’s a full fledged “scripting environment” with a ton of useful features:

  • It’s tab-based.
  • It has a formatted coloring system for your code.
  • You can run code by pressing F5.
  • You can highlight code and run that portion by pressing F8 or right-clicking on your selected text.
  • You can add breakpoints
  • You have a shell to use in the third window if you want to type something directly into Powershell.

You should also grab and install the powershell powerpack from the Microsoft website.  It includes an ISE pack which you can then get through the Add-ons menu within the ISE after it is installed.  Two great features are:

  • Ctrl-Alt-H – Brings up the get-Help for the currently selected text.
  • Alt-Y – Brings up a quick syntax-only version of the currently selected cmdlet

The Powerpack also includes a number of other really cool features.  I plan on posting my next article about WPK (think perl tpk).  It’s a robust module that allows you to implement .Net form elements to create a GUI for your powershell scripts.

One thing to note before you start running scripts with Powershell: Powershell scripts use the .ps1 extension for their files.  By default scripts are disabled within powershell.  In order to enable them you will need to look at and set the executionpolicy:

  • Use get-ExecutionPolicy to look at the current configuration for the executionpolicy.
  • set-ExecutionPolicy is used to set the execution policy.  To set the execution policy so that all local scripts can be run while remote scripts need to be signed use:
set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Now you are ready to go forth and create scripts that will chain together series of powershell commands with a brand new shiny interface to do it with.

Advertisements

2 responses to “Powershell ISE

  1. Tom November 18, 2009 at 3:57 pm

    Great post. I noticed the following:

    When trying to change the Execution Policy I received the error below:
    Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’ is denied.

    I believe this occurs if you are using UAC in Vista or Windows7. Running powershell as an admin resolves this issue.

  2. toenuff November 18, 2009 at 9:19 pm

    I just found out that powershell ise is the default editor when you right-click on a .ps1 file and click edit.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: