Prof. Powershell

Tip of the ISE-berg

Here's some of Prof. PowerShell's top Integrated Script Editor tricks.

The PowerShell ISE, or Integrated Script Editor, is intended as the bare-minimum scripting tool for IT Pros. Need to create a script? Don't open Notepad -- use the ISE. And even then, it is not intended as a full feature integrated scripting environment. Some of you will need more horse power from products such as PowerShell Studio from SAPIEN Technologies. That said, I thought I'd share some tips and tricks with on using the ISE. These are tips that work for me in PowerShell 4. I expect they should work with PowerShell 3.0 and hopefully PowerShell 2.0.

First off, you need to master some keyboard shortcuts. I tend to run the script editor maximized which means the console pane is also maximized. Switching between the two is as simple as Ctrl+R. Use Ctrl+3 to maximize the script editor. In fact this is so ingrained in me I mistakenly try to use the shortcut key to switch between applications. Likewise, if you have multiple scripts open, you can cycle between them with Ctrl+Tab. Using Ctrl+Shift+Tab will take you in reverse.

To load files in the ISE you have a few options. In the ISE, in the command pane you can use the psedit command.

PS C:\> psedit c:\scripts\qaudit.ps1

This will load the file into the ISE. Have multiple files to open? Try this:

PS C:\> psedit (dir c:\scripts\demo-word*.ps1).fullname

This will also work:

PS C:\> psedit (dir c:\scripts\demo-word*.ps1).fullname

From the PowerShell console, if the ISE is already open you can open a file in it.

PS C:\> ise c:\scripts\qaudit.ps1

Actually, you can use this command to launch the ISE and load a file. Unfortunately there doesn't appear to be a way to open the ISE with multiple files. However, once the ISE is open, you can send multiple files to it.

PS C:\> (dir c:\scripts\demo-word*.ps1).fullname | foreach {ise $_}

To close a file, use Ctrl+F4.

Another great tip: put your cursor anywhere in a cmdlet name and press F1. You should get help in the popup window, like you do when you use the newer –ShowWindow parameter. I love that.

Or if you prefer, configure the ISE to always get help online. In the ISE script pane run this command:

PS C:\> $psise.Options.UseLocalHelp=$false

Now when you press F1 for help, you will get the online help in your browser. This is a persistent change that will remain in effect until you set the value back to $True.

Finally, don't forget that the ISE ships with snippets. Press Ctrl+J to bring up the list of default snippets. This is a great way of rapidly building a PowerShell script or function. What are some of your favorite ISE tips and tricks?

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular