November 18, 2009
Posted by on
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.