PowerShell 2.0 ISE Integrated Scripting Engine (GUI)
The command line will always be at the heart of PowerShell. However, all scripting languages benefit from a GUI, or an Integrated Scripting Environment (ISE) as Microsoft describes this add-on console. If you merely use PowerShell to issue a few one-line commands then it’s probably not worth bothering with the ISE shell. But if you want to debug a block of code, or create and save .ps1 files, then the ISE will soon become your best friend.
PowerShell 2.0 ISE
- Guy’s Introduction to PowerShell ISE
- Getting Started with PowerShell’s ISE
- 5 Beginner’s Tips for Using PowerShell ISE
- See Also: PowerShell 3 ISE
In truth I was disappointed when I first saw the ISE, but that was back with PowerShell 2.0 CTP2. However, in CTP3 the graphical interface is coming of age, and by the final release, ISE will be a tasty appetizer for the main course of PowerShell 2.0. For once it seems that a program’s flashy front-end, namely ISE, is the last feature that Microsoft implements, and not the first.
Assuming that you have successfully installed PowerShell 2.0, to launch the ISE click on the ‘Start’ button, navigate to Start – All Programs – Accessories – Windows PowerShell, and then simply click on Windows PowerShell ISE. Incidentally, the underlying executable is powershell_ise.exe so you could fire-up the ISE in the time honoured way of typing powershell_ise in the run box.
Getting to Know the PowerShell ISE and $PsISE
PowerShell is a classic example of learning a feature in one area and then applying it elsewhere. For me it’s just a case of remembering this principle and applying it at every opportunity. For example, I love Get-Member or gm for short. Then I discovered that PowerShell’s ISE has its own built-in variable $psIse. It came as a pleasant surprise when the instruction: $psIse | gm returned useful information.
# PowerShell ISE v 2.0 $PsIse
$psIse | Get-Member
# Next, remove hash from next line
Interesting, but what is the point you may ask? Well, try this: $psIse.options.scriptpanebackgroundColor ="Cyan". Now experiment with other settings to suit your style.
For instance, you can reposition the bottom Command Pane with:
$psIse.options.CommandPaneUp = 1 (or zero)
Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft’s operating systems. Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.
Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory, or Exchange Server. Give this WMI monitor a try – it’s free.
A Reminder of the ExecutionPolicy for Running Scripts
Be default, and for security, you cannot run any PowerShell scripts. Now before you change this setting try the ‘get’ verb to see the setting before your run set-ExecutionPolicy. To see the options try this: help set-ExecutionPolicy.
# Now try:
As an aside, you can control the script behavior when you initialize a session by running PowerShell.exe with a -ExecutionPolicy parameter. However, I have not yet found a reason to operate this way, I prefer to make a lasting change with set-ExecutionPolicy. See more on Set-ExecutionPolicy
1) Select a Snippet
One advantage of the GUI is that you can select a block of code with the mouse, and click on the green arrow, which then runs that portion of your script. My point is that if you have a moderately long script you can highlight one part and run just that code snippet.
2) Find the Wiper!
If you look at the second pane of the ISE, then one tool stands out, and that’s the ‘Wiper’; its official tag is ‘Clear Output Pane’. As I was a great fan of the DOS cls (Clear screen), I love clicking on this tool to get a fresh screen.
3) New Tabs
This is so simple it seems hardly worth mentioning, but if you go to the file menu and click on ‘New’ you can easily access another script or window. I find these extra tabs useful for hopping between different versions of a script I am working on. As usual, Microsoft provide two ways of doing everything, there is a ‘New’ icon on the vertical toolbar.
4) Save Files
Once again, ‘File –> Save’ is pretty obvious, but for me this is a crucial reason for using the ISE rather than the raw command line. I make excessive use of saving scripts regularly, this to compensate for me not working methodically. I have learned from the hard school of knocks, in the past I have a script which is 95% complete, but then I do something silly and wreck it. If only I could go back to how it was 10 minutes ago. Well, if I saved a previous version with a different file name, then I can retrieve that stage of the script.
5) Debug Menu
By the time you explore the Debug menu, you are no longer a beginner. While my task of getting you started is over, I just want to reassure you that as you become more proficient at PowerShell, so ISE has powerful tools to correct any wayward code.
SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
Improvements in PowerShell 3 ISE
- A script pane for debugging scripts.
- An output pane where you see the results of commands.
- A command pane, I don’t use this much, it’s just like the Non-ISE version. Simply type a command and press Enter.
Note the tabs: I use these for testing different versions of my script and for researching with | Get-Member.
Incidentally, it’s possible to launch the ISE without loading $Profile with -No Profile.
While the ISE is the last feature that Microsoft has developed in PowerShell v 2.0, it will probably be the first place you go when you start using PowerShell regularly. As with any utility it’s worth spending a few minutes investigating all the tools, and as usual the 80:20 rule applies, you will only use 20% of the features 80% of the time. Furthermore, each person uses a different 20%, so my greatest joy is if you experiment to see which ISE features suit your style of scripting.
If you like this page then please share it with your friends
See more PowerShell examples for syntax
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.