Join Mike Pfeiffer for an in-depth discussion in this video Use cases for the PowerShell ISE, part of Up and Running with the PowerShell Integrated Scripting Environment.
- As you go from writing PowerShell one-liners to more lengthy and complex scripts, you'll quickly realize that writing code in a basic text editor can sometimes be a painful process. But the ISE is a great solution to that problem. The PowerShell ISE is one of two host applications for the Windows PowerShell engine. The first host application is the standard PowerShell console that you probably already use on a daily basis. The use case for this host application is interactive use. So you walk up to a server or a workstation. You fire up this PowerShell console and you can immediately start entering commands or running scripts and you generally get immediate feedback on whether or not those things are working.
Now the PowerShell ISE can do this as well but its primary use case is to provide a rich authoring experience for writing PowerShell scripts. The idea is to boost your productivity when writing code. For example, C# developers don't write applications in Notepad. They use Visual Studio. So as you might imagine IT ops personnel writing sophisticated scripts tend to do a lot better when they're using something like the ISE because it's much more robust. It provides things like syntax coloring intellisense, visual debugging, and a whole lot of other things that we'll take a look at as we move through this course.
So let's fire up the ISE and take a quick look at some of the benefits it provides versus writing code in the standard PowerShell console. So I'm going to close out of this. I'm going to go to the Start menu. And I'm going to type in powershell _ISE Let's go ahead and launch that. And when it first comes up you can see that we have two panes. There's a pane on the top. This is the script pane. So that you can see we have untitled1.ps1 This is basically a blank canvas for us to start writing a PowerShell script. Down at the bottom here we have the console pane.
And this is basically going to give us the output from the scripts that we write on the top pane. And it also serves as an interactive console just like the standard PowerShell console does. Now one of the first things that I like to do is come down to the bottom right-hand side and zoom in on the font size. Something like 185% is much easier to read. But the ISE has a lot of features and a lot of productivity benefits that we can use, such as intellisense. For example, I can type in a cmdlet or I can start typing a cmdlet like get- and notice that the intellisense screen gives us a drop-down of all of the cmdlets that match what I have already typed.
So I can continue typing here and it zooms in on the best match. So I have typed get-serv and notice that it's found Get-Service as a match. So I can tab through that, hit space, and I can start typing in parameters. So I'll hit a dash and it gives me a list of all the parameters that are available. So I can tab through the name parameter, hit space again and again I get intellisense for the parameter values. So intellisense is working for cmdlets, parameters, and values here. And let's say I'm looking for one called BITS. I can go ahead and hit enter here to go to the next line and continue writing my script or I can run the script by hitting this green button up at the top or I can hit F5.
But if we run that, you can see that we get the output here down at the bottom. Now, as we move on, we'll see how great the PowerShell ISE is for developing scripts but one of its best use cases is a replacement for the standard PowerShell console. You can actually collapse the script pane here and notice that now we just really have a blue screen where we can work in an environment that we're used to working in. But the cool thing here is we get the same exact intellisense experience. We can also copy and paste so I can just highlight this command. I can hit Control-C and then I can hit Control-V right on this line, hit enter and now I'm getting the output.
Now it seems like a basic function but in the standard PowerShell console copy and paste with traditional keyboard shortcuts has always been a challenge. So the PowerShell ISE is great for authoring scripts, but it's also a great replacement for that standard console. The copy and paste experience is better and the visual cues from things like intellisense provide huge benefits for productivity. Now you'll always want to make sure you're using the most recent bits for the ISE. So let's take a look at the ISE requirements for installing the latest version.
- Installing PowerShell ISE
- Using PowerShell tabs and profiles
- Writing, running, and saving scripts
- Working with snippets
- Adding custom menu items
- Working with add-ons