Windows Server How-To
Using the PowerShell Integrated Scripting Environment
Brien walks you through just some of the features of Windows Server 2012's ISE tool.
Microsoft provides the PowerShell Integrated Scripting Environment (ISE) as a tool to make working in PowerShell easier. In this blog post, I want to show you how to access and use this tool in Windows Server 2012.
If you are new to Windows Server 2012, it might at first seem that PowerShell ISE has been discontinued. After all, there is a Start screen tile for PowerShell, but not for PowerShell ISE. You can access PowerShell ISE by opening Server Manager and selecting the PowerShell ISE command from the Tools menu, as shown in figure 1.
You can see what PowerShell ISE looks like in figure 2. As you look at the figure, you will notice that the screen is divided into three sections. There is a toolbar at the top, a PowerShell interface in the lower left, and a list of cmdlets in the lower right.
The most useful part of the interface is arguably the list of cmdlets. As you begin scrolling through the list however, you will notice that the list is quite long. It can sometimes be a bit tedious to locate a specific cmdlet from within such a long list. The solution to this problem is to use the Modules drop down list. By default, the All modules option is selected, which means that you will see an unabridged list of PowerShell cmdlets. You can narrow down the list by selecting a specific module. For example, in figure 3 I have selected the Hyper-V module and now only Hyper-V related cmdlets are displayed.
Now that I have selected the Hyper-V module, let's pretend that I want to use the Get-VM cmdlet, but I am not sure how it works. When I select the Get-VM cmdlet, I am presented with a list of parameters for the cmdlet. You can actually use the GUI to enter data for the parameters and execute the cmdlet from within PowerShell ISE.
To give you a more concrete example, suppose that I wanted to get a list of all of the virtual machines that were running on a server named Lab2. To do so, I could enter Lab2 into the ComputerName parameter field and then click the Run button, as shown in figure 4.
As you look at the figure above, notice that all I did was to enter a computer name and click Run. PowerShell ISE actually constructed the command. I didn't have to know the command syntax in order to accomplish my task of displaying a list of the virtual machines that are running on the host server named Lab2.
Another thing that you might notice in the figure above is the Common Parameters option in the lower, right corner. As you can see in figure 5, the Common Parameters section allows you to control what happens if an error or a warning condition is detected when the command runs. You can also use the Common Parameters to request a verbose output.
As you have already seen, the main benefit to using PowerShell ISE is that it can construct PowerShell commands for you without you needing to know the syntax. The example that I provided earlier was OK, but in the real world PowerShell commands often consist of multiple cmdlets that have been piped together. Thankfully, PowerShell ISE can handle this too.
You might have noticed in the previous screen captures that the virtual machine TR isn't running. That being the case, let's pretend that I wanted to reconfirm the virtual machine's status and then start the virtual machine. To do so, I would start out by clicking on the Get-VM cmdlet and entering the name of the virtual machine. Instead of clicking Run however, I would click Insert. This causes the command to be inserted into the PowerShell window, but not immediately executed.
Now I can manually add a pipe symbol, click on the Start-VM cmdlet and click Insert again. Pressing Enter executes the full command, as shown in figure 6.
Now, let's pretend that I want to find out whether or not my virtual machine started. I know by now that I can use the Get-VM cmdlet to determine a virtual machine's status, so I decide to type the cmdlet rather than selecting it from the list. As I type, PowerShell ISE automatically assists me with the cmdlet's syntax, as shown in figure 7.
As you can see, PowerShell ISE is the perfect tool for anyone who wants to use PowerShell, but still needs a little bit of help. It can compose commands for you, or just help you with the command syntax.
Brien Posey is a seven time Microsoft MVP with over two decades of IT experience. As a freelance writer, Posey has written many thousands of articles and written or contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and healthcare facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. When He isn't busy writing, Brien Posey enjoys exotic travel, scuba diving, and racing his Cigarette boat. You can visit his personal Web site at: www.brienposey.com.