Learn Keyboard Tricks to Use the PowerShell ISE Easier
Summary: Learn how to use the Windows PowerShell ISE more effectively by leveraging keyboard shortcuts.
Hey, Scripting Guy! I am the network administrator for a large company, and we have to go through very rigorous testing before we can download and install software on our servers. This requirement has prevented me from using many of the community based script editors. I can use the Windows PowerShell ISE because it comes with Windows, and it is therefore considered part of the operating system. Unfortunately, it seems a bit cumbersome to use. Is there a way I can use some shortcuts to make things a bit easier to use? For example, I do not like having to use the mouse when I am working because it is a bit erratic.
Microsoft Scripting Guy, Ed Wilson, is here. This week I have been busy at work on the 2012 Scripting Games. I have written several events now, and I am pleased with the shape the events are taking. I think this year’s games are going to be a good challenge for both the beginner and advanced scripts. You should check out the 2012 Scripting Games Study Guide, and begin digging into the information that I provided about the ten areas of concentration for this year’s events. If you have time, you may also want to review study guides from the previous years. You’ll find them on the All Links on One Page. (You should book mark this page and keep it handy for the next several months, because I will be adding links to this page on a regular basis.)
WS, this is the third blog in a series about using the Windows PowerShell ISE. On Monday, I talked about how to Use the Windows PowerShell ISE to Work with Long Commands. In that blog, I contrasted some of the advantages (and disadvantages) of using the Windows PowerShell ISE as opposed to using the Windows PowerShell console. On Tuesday, I wrote Learn How to Use the Free PowerShell ISE to Edit Scripts. In that blog, I covered the script execution policy, clearing the output pane, and a number of keyboard shortcuts that make cutting, copying, and pasting code in the Windows PowerShell ISE easier to accomplish.
Today, I want to continue the discussion about keyboard shortcuts in the Windows PowerShell ISE. To create a new script pane (or to add a new tab to the Windows PowerShell ISE), click the paper icon on the tool bar. To open a script for editing, click the folder on the tool bar. To save the script, click the floppy disk icon on the tool bar. These icons are shown in the image that follows.
Not all of the capabilities are available via the tool bar. Other capabilities, such as opening a Windows PowerShell ISE tab that works against a remote machine, are available via the File menu. Here are a list of keyboard shortcuts that perform the same actions.
New Script (pane)
Ctrl + N
Open Script (or other file)
Ctrl + O
Ctrl + S
Alt +F + A
New PowerShell Tab
Ctrl + T
Close PowerShell Tab
Ctrl + W
Ctrl + F4
New Remote PowerShell Tab
Ctrl + Shift + R
One of the interesting things about the Windows PowerShell ISE is the use of multiple tabs, and multiple script panes. The easiest to understand are multiple script panes. Opening the Windows PowerShell ISE automatically opens a blank script pane. If I then open a script, it appears on a new script pane, and the original blank pane still appears. If I open three scripts, there will be four script panes: the original blank script pane, and the three panes that contain the three newly opened scripts. This scenario is shown in the image that follows.
One thing to keep in mind is the title of the untitled script pane changes based upon how many times it opens or closes. In the previous image, the untitled script pane is up to untitled11.ps1. This means 10 untitled scripts have opened and closed (perhaps they were saved as scripts, or simply discarded.)
A new Windows PowerShell tab is not quite as easy to understand, because at first glance it does not appear to work. A new Windows PowerShell tab is tied to the command pane and to the output pane, but not to the script pane. In fact, a new Windows PowerShell tab does not create a new script pane at all. In the following image, you can see that the PowerShell 1 tab contains the output that is associated with the Get-Process cmdlet.
In the image that follows, the PowerShell 6 tab appears. It contains the results of the Get-Service cmdlet.
Using multiple Windows PowerShell tabs is a great way to execute long running commands, and to see the output from multiple commands. In addition, it is an excellent way to work with multiple remote systems at the same time.
WS, that is all there is to using the command line with the Windows PowerShell ISE. Windows PowerShell ISE Week will continue tomorrow when I will talk about more cool things.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy