Understand PowerShell ISE

Both PowerShell and PowerShell ISE  is simple and easy to use script execution environment But PowerShell ISE (Integrated Scripting Environment) provides more flexibility because of its GUI. It provides various controls and features, which help developers to create, edit, update, debug, and refine PowerShell script.

A typical PowerShell ISE environment looks like below and it has 3 panes –

  1. Script Pane
  2. Output Pane
  3. Command Pane

powershell-ise

PowerShell ISE is a feature-rich GUI as compared to the PowerShell console. The ISE provides a variety of shortcuts and controls, user help and other easy to use features that are not present in PowerShell command Line. For example, the ISE supports – IntelliSense, Indenting of the script, multi-line editing, tab completion, syntax-based coloring, selective execution, debugging with breakpoints in the script, help, and multi-language support.

Here is a screenshot above you see only one window in script pane named “untitled.ps1” but we can even open multiple script windows at the same time. It is useful when we are debugging a script, which uses the function defined in other modules or script.

Features of PowerShell ISE

  1. Rich Command Panel – On the right-hand side, you find the PowerShell command panel if it is not visible to you click on “Show Command Add on” shortcut from the toolbar. Command panel contains all PowerShell scripting language cmdlets developer can find the commands arrange in alphabetical order or by group or it can filter by typing the initials.
  2. Reduce total Effort – While writing the script here are many things, which help you reduce your total effort like – IntelliSense from popup you can select the command in the given list. Also, provide proper indenting so that developer can also understand the code and modify the same according to requirement.
  3. Debugging – PowerShell CLI does not provide debugging of code if you want to debug in PowerShell CLI you have to write a custom logging to debug the code. However, in PowerShell ISE you can debug each line also you can add the breakpoint to hold the control and manually inspect the variable or object value at a specific point.
  4. Execution – PowerShell ISE provided both complete execution and selective execution of the script. You can copy any script and paste in PowerShell ISE script pane and press F5 to execute it until the end or you can select a specific portion of the script to check the output of that specific portion of the script.

           Note: Selective execution is not permitted in PowerShell command Line.

  1. Code Snippet –Another key feature in PowerShell ISE is snippets, Code snippets are commonly used standardized short code pieces that you can insert into your script by picking from a populated list. To add a snippet in the script pane, just need to click on CTRL+J. This launches a pop-up window that lists down available snippets and then we can scroll down to select the desired piece of code into our script. Administrators also can build and add their own snippets into the default collection.

powershell-ise-code-snippet

      6. Customization – PowerShell ISE has a lot of options, which you can customize according to your requirement open the tools menu and click on options to customize the default settings.

Key Difference between PowerShell & PowerShell ISE

SNo. Features PowerShell PowerShell ISE
1. Environment Support only CLI It provides a GUI environment.
2. Editor Only single-screen for input and output. It has Script pane, output pane, and command pane.
3. Debugging No – You have to write a custom logging to check variable values. Yes –it has a debugging feature inbuilt.
4. Toolbar, IntelliSense No Yes
5. Execution Complete Complete and Selective both
6. Help No Yes – Type Write-Host in Command pane and Press F1. A help window will open and show the help of that cmdlet.

How to Execute the Powershell ISE Script

PowerShell ISE and PowerShell Console both are used to execute the script but in PowerShell ISE there many different best practices to execute the script –

  1. If the script is, one-liner or just needs to check some value of something then write the command in output pane directly and press enter to execute the same. This you can do from Script pane as well just type the command and press F5 or run green button from the toolbar.
  2. Suppose if anyone sends you a script and you need to review and maybe to need to modify the same then open the same in script pane & modify it and press F5 to execute.
  3. If you have .ps1 file anywhere in your file system just go that path using “cd” command in output pane and type the first letter of the script name and press tab a script name appears then press enter to execute the script.

I hope you now have some level of understanding of how to use PowerShell ISE. This is flexible as compared to the PowerShell console and provides feature-rich GUI.