Summary: Learn how to use the Windows PowerShell ISE to work with long commands and make things easier to understand.
Hey, Scripting Guy! I don’t get the purpose of the Windows PowerShell ISE. I mean, we have the Windows PowerShell console, and most of the time, all I am doing is typing a few commands there. Why should I use the Windows PowerShell ISE when it takes at least three times as long to load on my computer as the Windows PowerShell console does?
—PG
Hello PG,
Microsoft Scripting Guy, Ed Wilson, is here. Wow, it is a little more than a month until the Central Ohio PowerShell Users group hosts the first ever PowerShell Saturday event. The Scripting Wife and I are looking forward to this event. (In fact, the Scripting Wife did a lot of the organization for the event along with Wes Stahler, Ashley McGlone, and Brian Jackett.) This event will be awesome and several Windows PowerShell people are coming in from adjoining states to take part in this exclusive event. I will be presenting a day-long track that covers beginning with Windows PowerShell, and one of the things that I will talk about is the Windows PowerShell ISE.
PG, one of the things you might want to do is to read the Scripting Wife blog, The Scripting Wife Uses the Windows PowerShell ISE. It provides a fun background for my answer today.
I placed the Windows PowerShell ISE on my task bar, right next to the Windows PowerShell console; this makes it easy to use and to get to. If you do not want to do that, it is always possible to launch the Windows PowerShell ISE from inside the Windows PowerShell console by typing the command ise. This command, ise, is technically an alias. The executable name is powershell_ise.exe. The ise alias is resolved by using the Get-Alias cmdlet, as shown here.
PS C:\> Get-Alias ise | fl *
HelpUri :
ResolvedCommandName : powershell_ise.exe
ReferencedCommand : powershell_ise.exe
ResolvedCommand : powershell_ise.exe
Definition : powershell_ise.exe
Options : ReadOnly, AllScope
Description :
OutputType : {System.String}
Name : ise
CommandType : Alias
Visibility : Public
ModuleName :
Module :
Parameters :
ParameterSets :
This actually is a cool trick, and it is something that I have not talked about before. Every time I have created an alias, it has been for a Windows PowerShell cmdlet or a Windows PowerShell function. But I can also create an alias for an external executable. For example, I can create an alias called net for the command netsh.exe. Although it is not a huge time savings, it does illustrate the point. The commands shown here create a new alias named net. Use the net alias to enter the net shell, and then use the exit command to leave the net shell and return to the Windows PowerShell prompt.
PS C:\> New-Alias -Name net -Value netsh.exe
PS C:\> net
netsh>exit
PS C:\>
The upper pane of Windows PowerShell ISE is the script pane. Just because it is called a script pane does not mean you have to write a script. In fact, I often use it to organize Windows PowerShell commands because it lets me see a better picture of the flow than command continuation characters in the Windows PowerShell prompt. In the image that follows, I type a three-part command that retrieves process information, selects the name and process ID of each process, and displays the output in an automatically sized table.
Four things top keep in mind here are:
The image that follows illustrates the same three commands and their associated output as it appears in the Windows PowerShell console.
There are also several considerations when running commands in the Windows PowerShell console:
In the Windows PowerShell ISE, when working in the script pane, you can type as many commands as required, and they do not execute until you press the F5 function key (ensure that function lock is not turned on on your keyboard), or you press the large green triangle under the Help menu heading.
One thing that I really like about the Windows PowerShell ISE is the ability to run only a portion of a command in the script pane. The ability to run only a portion of a command is useful not only from a troubleshooting perspective, but it is also useful when running demos whilst making presentations about Windows PowerShell. When highlighted, a selection of the script runs upon pressing the F8 function key or pressing the small green and white icon. This is shown in the image that follows.
PG, that is all there is to getting started with the Windows PowerShell ISE. Windows PowerShell ISE Week will continue tomorrow when I will continue the discussion.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy
Hi Ed,
an intersting comparison bewteen the ISE and the console!
Preferring GUI tools to edit scripts is not a fault, I suppose :-)
I'd like to see the next version of the ISE, already available in CTP2,
but only on english OS :-(
btw. is there a way to install WMF 3.0 CTP2 on a german WIN7 OS?
Klaus (schulte)
@K_Schulte It is all about choice. Some people prefer a more graphical environment, and others like only using a rather non graphical console. I am not yet allowed to talk about next generation Windows yet, so I cannot comment on language availability.