Command Line

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
or

Already have an account? Sign In »

Time
1 hour 43 minutes
Difficulty
Intermediate
CEU/CPE
2
Video Transcription
00:00
Hello, everyone. I'm instructor Gerry Roberts, and this is Power Shell. Scripting
00:05
this video, we're gonna talk about what a command is and how commands are structured in power show.
00:12
First of all, what is a command? Simply put, command is just a bunch of words or a single word that's been put together to do something, such as get a vet log, which would help you retrieve into that long and Windows in power shell. They're also called CM deal. It's or command blitz.
00:32
There are predefined CMD, let's and power show and some that you can add.
00:37
Packages of commands are offered called modules, so there are modules for some things that you can act.
00:42
These could be for a program or specific task. For example, there are modules specifically made for Asher, and there are actual modules made specifically for scripting tasks.
00:56
So in Power Shell, there's usually a structure to the command of the CME. Deal it here. We have an example of a command that's trying to get an event log
01:07
and specifically looking for the one called Security
01:11
on the Computer Jerry PC to and at the end we're telling it that we want a lot of information. Verbose means
01:21
that you're gonna add a lot of extra information.
01:23
Now, if we break down this command, we can see that at the beginning. The first item is a verb. The second item is in now, typically in power. Shell commands are structured with a verb. Now, this was a get dash of that log. And a lot of times you'll have commands that are get dash something.
01:42
You also have commands
01:44
that are set dash something or add dash something a lot. Now, the difference here is when you do get dash something, you're usually just pulling information. When you're doing a set dash something, you're usually actually setting of value, such as a user name or password for account.
02:00
And if you're doing an ad dash something, you're usually adding a new something like a new user or a new group.
02:08
The next thing you'll notice after our verb noun structure is a parameter. Ah, parameter is an item where we can put information in here. We have a parameter for log name, so we're telling it that we're looking for a specific log
02:25
and then putting in a parameter value,
02:29
so those which log to find. In this case, it's security.
02:34
Now. We also have another parameter here. Computer name. So now we're telling it, we're looking for the long name security, and then we're gonna look afford on this specific computer, and we pass the value Jerry Dash pc to now notice here that these parameters only have a single value.
02:53
Some parameters can have multiple values, and those values
02:58
typically are separated by commas or quotation marks, depending on the structure of that particular parameter. Now the end, you notice that you do have a switch parameter. Now there are different types of parameters. Here we see parameters that take values
03:15
and search. Perimeter is a primer that does not take you
03:19
value but does do something
03:23
now. Now's and parameters air normally in singular form,
03:28
that just means commands of parameters will not usually have an s. And and so here's an example. We have get Dash 80 user. When we put that command in and we put in the dash is for the parameters that we put in. Those piece of information will be able to get information about an active directory user.
03:46
However, if we added it s at the end. We did get Dash 80 users.
03:51
We're gonna get a big old, nice block of red text. That's an error, and it's not gonna be happy. So make sure when you're typing out this command that you look and see is this one that has it s because those are very rare. Sometimes those are things like get
04:08
process or get service's or things like that from the computer where the name of the item already had an s.
04:15
Most modules also have information on where they come from. In the example above. When you look at that, CMD let you see the A D for active directory.
04:28
So another thing you'll notice when you're putting in commands. If it's from a specific module, you're probably gonna have some sort of information in it to tell you where it's coming from,
04:36
such as our active directory example.
04:41
Now spacing in case sensitive other considerations. Watch your spacing.
04:46
Seriously, Improperly. Space command's just are not gonna run. You're gonna get a whole lot of red tax, do you're not gonna be happy.
04:54
Power Shell uses the spaces to know when to look for the next item in the list.
05:00
It will continue until it is lost if there is not proper spacing. So what will happen is the command will run. And then if it hits where it's not proper spacing is goingto hopes. I don't know what that is. Here's a bunch of ares tell you that. I don't know what that ISS
05:15
Another thing with power showcase sensitive
05:17
some modules and power shell, our case sensitive summer. Not quite a few of them. If you were to write that get 80 user we saw earlier, all in low caress would still work. But the important part to remember is things that our values, like Valium, paths,
05:33
file names, folder paths All that should be properly capitalized. Of what confusion? Because it's not gonna find what you need or do what you need
05:42
if it doesn't know the proper value. If you just not sheriff a module requires proper capitalization. Just do it anyways. It's not gonna hurt to do capitalization when you don't need to. Necessarily the other thing. Use proper simple CZ. For example, don't accidentally put in underscoring a command, requires a dash
06:01
and put your slashes in the correct direction.
06:05
Bio paths or anything like that, that requires a slash. If the slashes in the wrong direction, it's not going to find it. It's not gonna do it. You're gonna have a bad day, so make sure you put your slashes in the correct direction.
06:20
All right, so post assessment question time, What is a parameter called has no values being passed through it? If you remember back a couple slides, we talked about that. Is that a zero parameter?
06:34
Is that a switch parameter?
06:36
Is that a blank prouder? Our parameter Noel, you can pause for a moment to figure out your answer
06:45
are right. So our answer here is be a switch perimeter. A switch parameter has no value being passed through. It will only have one effect, for example, and our example earlier, verbose for Bose has put there to add additional information about the output of the item
Up Next
Intro to Powershell Scripting

In this course, you will learn the fundamentals of Microsoft Powershell, which is a popular task automation and configuration management framework. In this course you will learn the basics of the tool, to get started scripting today!

Instructed By