- When you start scripting, you're going to
start using Notepad, and I want to stop you
from doing that right now.
There is no good reason to write scripts in Notepad,
and let me give you the reason why.
Because you get something absolutely free.
With PowerShell comes the ISE.
And I'm going to strike enter.
Now, there are third party products that you can
get that are more professional development
environments for PowerShell scripting, but since
you're getting started with PowerShell, there's
nothing wrong with using this.
This is a great learning tool to get started with.
This is free.
It comes built in already.
It's the integrated scripting environment
and let me take you on a quick tour
and then we'll build a script in here.
So over here to the right is a way that you can
call up commands really quickly and take a look
at those commands and the parameters that
they have that you can find as you're looking
for them and getting a list of them.
Now, I'm going to temporarily turn this off
so I can get better screen real estate.
And here this little button will turn it back on.
So you can turn this on and off at will.
So I'm going to go ahead and close this.
Now right now it's showing me a view of the console
because I haven't opened up a script yet.
I'm going to go ahead and open up a script,
and I want you to notice.
See the button over here I clicked?
This is a two pane view.
Now, this might be, I'm going to maximize this on my screen.
This might be too small for you to see.
It's too small for me to read.
So if you look down here in the lower right hand corner,
here's a zoom key, and I use this all the time.
I'll show you why.
I zoom in and out of this constantly.
So I'm going to zoom in to make this a little
bit larger so it's easier to read.
Now, this is a two screen display.
Here's where your script will go, and when you
execute your script, the results will be displayed
here in this console view.
Now, take a look at these three buttons.
I want to show you what these do.
Because you might prefer a different layout.
If I hit this, it splits the two.
Now, if you're on a single monitor, you might say
this doesn't make a whole lot of sense to me.
That's okay.
If you have two monitors, it suddenly will.
Because what you do is you put this bar in the middle
between those two monitors, and then you've
got a script pane on one side and a console
pane on the other monitor.
Here's the advantage.
You can do get help and look at the help files
over here while you're scripting.
So it works out really well.
There's also a single pane view.
This gives you the maximum for whatever
it is you're working in.
Now, I'm going to show you that you can hit
control R to flip between the two screens.
I'm hitting control R.
And this is a way that I usually work, because
I have one monitor, but let's go to this pane for a second.
I'm going to show you something interesting about
why you're going to want to use the ISE over Notepad.
Watch what happens when I start to type.
It has intellisense.
In other words, look at what it's doing.
It's bringing me up get service and it's
showing me the syntax for get service.
I can tab complete it.
I'm going to hit dash n.
See, it's showing me the parameters.
You'll also notice that it's color syntax.
Your eyes become accustomed to this color syntax,
and what happens is you can spot syntax mistakes
before you've even tried to execute it.
So this helps you script better and it's
kind of helping you along the way.
I can hit a pipeline and watch what happens
when I try to pip this to something.
See that little red under bar there,
that little red squiggly?
If I hover over it, it's saying you've got an empty
pipeline, you need something after this.
So then I could do select object.
And when we script, we always use the full
commandlet names, no aliases, and we
always put in the parameters.
Property name comma status.
When I'm ready to execute this, I can hit
the run script or press F5.
And you'll see that the results get displayed down here.
This is much better than Notepad.
But let me show you something else
that's really interesting.
I'm going to go to a full screen display.
And I'm going to hit control R.
This console view, let me clear the screen for it,
some people like to use this console view rather
than the default console view, and here's why.
This console view is the great old fashioned
standard console view.
We use it all the time.
This one, watch.
Get service.
See, it has intellisense just like the scripting pane does.
This can make your life easier.
It has color syntaxing just like the scripting pane.
So some folks like to try to solve their problems
in this console and then copy them to the script.
Let me give you an example.
I can highlight this.
I can hit control C, hit control R to flip over here.
Let me get rid of this one just so I can
show you that it works.
And hit control V.
I can cut and paste very quickly and easily.
So I've been using control R to flip between them,
but you can see that there's a lot of advantages to this.
Now, why do I still use the old console?
Some folks would say, well, it's because you
started out with it, you know, seven, eight years
ago, whatever, and you're just used to it that way.
Nope, I always recommend that you still keep a
skill set at using the standard console because
when you walk up to a server, you're not going
to have the ISE, and so you're still going to be
able to need to be able to troubleshoot syntax
errors and to deal with this console.
So you should know them both.
And actually, I like to solve my problems here
and copy them into the ISE.
And I also test everything, test all my scripts,
from this console.
So that's a quick tour of the ISE.
Now, there are other features.
It does have a debugger in it.
You can change the view and some of
the coloring of how it works.
But this is a great start to using the ISE.
With this, we're going to build a script,
but we're going to build a better script
than what you probably are thinking about
when you think about scripting.