- [Instructor] In this segment, we're going to talk
about and look at PowerShell.
Now, PowerShell is a powerful, no pun intended,
task automation and configuration management framework
consisting of a command line shell and scripting language.
And it's straightforward and easy to learn.
Now, the quickest way to find PowerShell
on a Windows device is to go right to the search bar
and type PowerShell, and it will bring up the app.
It's gonna give me an option of running
as a currently logged in user or as the administrator.
I'm gonna choose to run as the administrator.
If I go down to my task bar,
I'm gonna see the icon to open it up.
That's going to bring me
to the Windows PowerShell shell, if you will.
Tells me I'm running as an administrator
and I'm right here at the prompt.
Now, compiled commands and PowerShell
are called commandlets.
Commandlet names have the form
of the singular verb dash noun command
to make them really easy to discover and to remember.
So I wanna give you just some examples
of how we interact with PowerShell.
Some really simple examples to begin with.
Let's say I wanna learn what processes are running.
Remember, I'm gonna use the form verb noun.
So the verb is get
and the noun is gonna be process, get process,
and that's gonna come back
and show me all the processes that are running
on this system.
Maybe I wanna know what services.
Again, verb dash noun.
So get-service.
There are all my running services.
Well, I probably have a lot to learn about using PowerShell
so I really wanna become familiar
with the help functionality.
So if I wanna learn about help,
what do you think it's gonna be?
Well, let's start with the verb get and then help.
And that's gonna bring up information
for me about how to use help within the PowerShell.
So the entire PowerShell help system
I'm gonna just use cls to clear the screen.
Maybe I wanna get help about how I interact
with commands that have the word "service" in it.
Well get-help and then service.
And that's gonna come back
and tell me about all of the commandlets or functions
that are associated with the term service.
And it will give me a synopsis.
If I wanna learn more about a particular one,
let's say the first one,
the list, get-service, well, get-help.
And then what do you think comes next?
Well, get-service.
And that's going to give me specifics
about how to use that command, the synopsis,
the syntax, description, related links, and other remarks.
Now there are an awful lot of commands
that are at your fingertips.
Well, really, we should call them commandlets and functions.
So how do you find out what they are?
Well, you know what?
There's a commandlet for that.
It's gonna be get-command.
And what we see here is a list
of all of the commands and functions that are available
to us to use within PowerShell
and obviously, it's a really, really extensive list.
So I'm just gonna stop this list.
I'm gonna hit Control + C, so we can continue on
and I'll do cls again, just to clear the screen.
So let's do more
than just run a list of processes or services.
Let's actually invoke some commands.
So the first one I wanna show you
and I'm gonna invoke-command, is that I wanna go out
out to the event log, my system event log,
and I wanna have displayed the last 50 entries,
meaning the newest 50 entries.
So I'm gonna say invoke-command.
And the command I'm gonna invoke is ScriptBlock.
And then I'm gonna put in some parameters, get-EventLog.
And the one I wanna get is system.
And I wanna get the newest 50 entries.
So I'm gonna say newest 50 and close up those parameters.
And there we go.
That's the newest 50 entries in my event system log.
Now I can query almost anything
with PowerShell on my local system
as well as other systems I'm connected to
as long as I have the appropriate rights.
But I can also go outside my network.
I can go out to the web and query the web.
I'm gonna do another invoke command.
This time, I'm gonna go out to a Microsoft page
and I wanna discover all the links on that page.
So I'm gonna say Invoke-WebRequest
and I am gonna go out to https://docs.microsoft.com.
And I wanna get information
about all the links that are on that page
and what their reference is.
And what just got returned to us
is all the links that are embedded on that page
both within the site and external to the site.
You know, these are just some really simple examples.
You know, you can use each commandlet separately
but the power of PowerShell
is realized when you combine these commandlets
to perform complex tasks or to automate repetitive tasks.
So I really, really wanna encourage you
to get to know PowerShell.
And there are so many resources available to you out there.
There are open source resources.
There's tons and tons of books that have been written.
There's great help screens embedded in PowerShell.
You know, getting to know PowerShell will make your job
a lot easier and you're just gonna be amazed
at all the things that you can do.
So get to know PowerShell, you know, really start using it.
And that my friends, is a closer look.