Command Line

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *

Already have an account? Sign In »

1 hour 43 minutes
Video Transcription
Hello, everyone. I'm instructor Gerry Roberts, and this is Power Shell. Scripting
this video, we're gonna talk about what a command is and how commands are structured in power show.
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.
There are predefined CMD, let's and power show and some that you can add.
Packages of commands are offered called modules, so there are modules for some things that you can act.
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.
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
and specifically looking for the one called Security
on the Computer Jerry PC to and at the end we're telling it that we want a lot of information. Verbose means
that you're gonna add a lot of extra information.
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.
You also have commands
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.
And if you're doing an ad dash something, you're usually adding a new something like a new user or a new group.
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
and then putting in a parameter value,
so those which log to find. In this case, it's security.
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.
Some parameters can have multiple values, and those values
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
and search. Perimeter is a primer that does not take you
value but does do something
now. Now's and parameters air normally in singular form,
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.
However, if we added it s at the end. We did get Dash 80 users.
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
process or get service's or things like that from the computer where the name of the item already had an s.
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.
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,
such as our active directory example.
Now spacing in case sensitive other considerations. Watch your spacing.
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.
Power Shell uses the spaces to know when to look for the next item in the list.
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
Another thing with power showcase sensitive
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,
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
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
and put your slashes in the correct direction.
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.
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?
Is that a switch parameter?
Is that a blank prouder? Our parameter Noel, you can pause for a moment to figure out your answer
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