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.

[Click on image for larger view.] Figure 1. You can access PowerShell ISE through the Server Manager's Tools menu.

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.

[Click on image for larger view.] Figure 2. This is what the PowerShell ISE window looks like.

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.

[Click on image for larger view.] Figure 3. You can narrow down the list of cmdlets by selecting a specific module.

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.

[Click on image for larger view.] Figure 4. You can execute commands directly through PowerShell ISE.

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.

[Click on image for larger view.] Figure 5. You can use the Common Parameters section to respond to errors or warnings or to request 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.

[Click on image for larger view.] Figure 6. You can use the Insert button to stitch multiple cmdlets together.

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.

[Click on image for larger view.] Figure 7. PowerShell ISE helps with the command syntax.

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.

About the Author

Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and 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 health care 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. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.

Featured

comments powered by Disqus

Subscribe on YouTube