Learn about Windows PowerShell
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
Two other very useful keyboard shortcuts for the ISE are Ctrl-D, which switches focus to the command line, and Ctrl-I, which swithes focus back to the script pane.
that's really astonishing, how much the ISE can do if you have a closer look at each funtion!
In fact I never did recognize all the details ...
One thing that doesn't work in a localized german version as I'm running is:
The ALT +F +A is related to the english language version only.
We have to press ALT +T +T here.
Datei .... Speichern unter ...
I would also add 3 more: ctrl + 1, 2, 3 to switch between different pane arrangements and ctrl +R to show/hide script pane... :)
@BigTeddy those are indeed great shortcuts - very useful. Thank you for reminding me.
@K_Schulte Yes, the Alt + F + A shortcut is language specific. In fact, there are many of these kinds of shortcuts and they are generally indicated by a underline of a letter in the menu name. I only included this one here, because there is no other shortcut for saveas -- and it is something I need to do all the time, so I taught myself that one. Thanks for pointing out that it is language specific.
@Bartek Bielawski I forgot about those shortcuts. Thanks for reminding me.
Another hand shortcut: CTRL + G to open the Go To Line dialog.
@R. Derickson That is a great shortcut, and it is very useful as well. Thanks for sharing.
Sure saves a lot of Trouble, especially while viewing previous cmdlets............
I haven't looked into integrating Powershell with Visual Studio--any one have any hints?