WEBVTT

00:08.470 --> 00:15.670
Anytime that you start to work in a script you start to work with a greater level of complexity.

00:15.670 --> 00:23.500
Scripts include many components and each of those can potentially introduce an error or block to use

00:23.500 --> 00:30.900
how long you have to spend the bargain as grip you should test individual commands in the windows powerful

00:30.900 --> 00:32.240
console first.

00:32.320 --> 00:40.280
If you have each command working individually by use and test well if you can paste that command into

00:40.300 --> 00:44.040
script and probably have fewer problems with it.

00:44.110 --> 00:50.920
For example when you start to really command pro-white test whaler's for each parameter then you can

00:50.920 --> 00:59.530
run the command by itself in elections so you might use localhost for a computer name even though your

00:59.530 --> 01:04.170
final script might might not use a local host.

01:04.180 --> 01:11.330
For example suppose that your Rusk's to create a tool that can be used by your Help Desk.

01:11.400 --> 01:20.200
The team must retrieve the 50 most recent security round lock cantrips from a designated computer.

01:20.230 --> 01:28.510
The tool must retrieve only event lock and terrorists that have a specified event identification or

01:28.510 --> 01:29.240
ID.

01:29.290 --> 01:37.950
You might create the foreign command as the basis for this year to get event log log name security computer

01:38.020 --> 01:39.500
name local host.

01:39.560 --> 01:48.130
Pipe it to wherever anti-ID equals foetid 6:24 and pipe it to select first 50.

01:48.250 --> 01:57.980
This command to use as well such as a local host and Event ID 40 6:24 that will not always be used to

01:57.980 --> 02:02.050
add the final Tula's wrong by starting with this test.

02:02.050 --> 02:09.040
Well yes you can make sure that the command works correctly so when you have the command working correctly

02:09.310 --> 02:12.210
you have to identify the well use them.

02:12.250 --> 02:17.230
That might change every time someone runs the command.

02:17.230 --> 02:25.940
Frequently this will be the same well that you used test will use for when you are testing the command.

02:26.110 --> 02:30.220
For example and the following commands are also to well use.

02:30.340 --> 02:39.230
That might change Getaround local org name security computer name local host pipe where around today

02:39.290 --> 02:44.260
equals 46 24 and select first 50.

02:44.260 --> 02:51.910
Please know that the Brisard An example may require that you manually start the remote registry service

02:52.210 --> 02:54.040
if it is not started.

02:54.070 --> 02:59.380
This is our local host and Forte 6:24.

02:59.470 --> 03:07.180
Remember that the tool is supposed to retrieve designator to run tidy from a specified computer to make

03:07.180 --> 03:10.090
both of those whaler's changeable.

03:10.090 --> 03:17.210
The tool is always supposed to retrieve it when to look and dress from the security event log and it

03:17.530 --> 03:22.860
it is always supposed to retrieve no more than 50 entries.

03:22.870 --> 03:28.810
That means the well wealthiest security and 50 are not changeable.

03:28.810 --> 03:31.070
Those can be left alone.

03:31.240 --> 03:37.780
Now when you have this come out and Blaze you can start to create a script file to take advantage of

03:37.780 --> 03:40.970
the newest feature same windows power shell.

03:41.020 --> 03:48.790
Start your script with the command led by and then attribute this attribute enables certain windows

03:48.790 --> 03:57.010
powers of features in a script and differentiates this group from earlier versions that do not to use

03:57.130 --> 03:58.480
those features.

03:58.480 --> 04:01.350
Next create a ram block.

04:01.390 --> 04:07.250
It must come directly after the common lead bind an attribute inside the block.

04:07.300 --> 04:16.150
You create a comma separated list of parameters each parameter is basically a variable and so each parameter

04:16.150 --> 04:20.050
name starts with a dollar sign as a best practice.

04:20.050 --> 04:29.320
Also define the data type for which parameter data types include string for strings and for interviewers

04:29.620 --> 04:33.150
switch for on off switches and so on.

04:33.310 --> 04:42.640
As a note here you can not use the command led by an attribute unless you also use a brand block liberal

04:42.670 --> 04:44.690
blog can be added to.

04:44.790 --> 04:52.510
If your script will not need to use any input parameters so you can also define a default value for

04:52.540 --> 04:54.300
parameters at default.

04:54.300 --> 05:02.230
Well here's a good idea when well you might have to change only occasionally but will usually be the

05:02.230 --> 05:02.610
same.

05:02.620 --> 05:11.770
Well each time the script is wrong you can also identify some or all parameterless has been mandatory.

05:11.950 --> 05:19.750
When you identify a parameter as a mandatory window spokes Melville performed for a while you're one

05:19.750 --> 05:25.330
the person running the script and does not require one in advance.

05:25.360 --> 05:30.660
Default values are ignored when a perimeter is marked as mandatory.

05:30.670 --> 05:34.930
For example you might now have a script that looks as follows.

05:35.030 --> 05:44.080
Restart it with a command led by engine attribute then continue with Behram block where we specify the

05:44.080 --> 05:45.390
parameters.

05:45.400 --> 05:56.680
So we identify perimeter as mandatory then define that data type istream for computer name and integer

05:56.680 --> 06:00.750
for anti-ID computer name and Toronto idea.

06:00.840 --> 06:09.660
Our parameters here as you can see they look like variables and reclose a ram block here.

06:09.790 --> 06:14.830
And below we have a set of commands that are to be wrong.

06:14.920 --> 06:23.590
And this script we have got to and lock a log name security computer name will be taken from computer

06:23.590 --> 06:34.290
name parameter and when TDD will be equal to the Grant ID perimeter and we pipe it to select first 50.

06:34.380 --> 06:42.430
Notice the perimeter Mame's have also been used instead of the old test 12 years Lebaran block defines

06:42.760 --> 06:44.020
the parameters.

06:44.230 --> 06:48.990
And then you can use Libera emitters instead of the test.

06:49.000 --> 06:56.830
Well this in your command please know that your parameter names will appear however you type them in

06:56.830 --> 06:58.320
the Behram block.

06:58.450 --> 07:01.900
Although windows power shell is not case sensitive.

07:01.900 --> 07:10.060
This command to used computer name type in such a way so that the parameter would be displayed and to

07:10.060 --> 07:12.490
be more consistent with.

07:12.550 --> 07:16.550
Come on let's that have a computer name parameter.

07:16.630 --> 07:24.750
Also know that in this example this group's computer name parameter is being passed as well to the computer

07:24.760 --> 07:28.430
name parameter or that Getaround lock command.

07:28.450 --> 07:34.180
There is no technical reason for these two to share the same name.

07:34.180 --> 07:43.480
However they're using computer name parameter makes the script parameter consistent with the parameters

07:43.570 --> 07:45.910
of the windows POAs shell commands.

07:46.060 --> 07:54.650
Windows power cell gives you some flexibility in how you format the RAM block the Weinrich while true

07:54.840 --> 08:00.420
is that that each parameter be separated from the next by a.

08:00.640 --> 08:04.370
The last parameter is not followed by a comma.

08:04.510 --> 08:08.660
So if you type the following it is acceptable.

08:08.770 --> 08:18.640
Common led by bind an attribute then the param block which is typed in one line but the parameters themselves

08:18.970 --> 08:20.940
are separated with comma.

08:21.100 --> 08:29.680
More experienced users prefer the first example where you type each parameter on the new line because

08:29.680 --> 08:32.650
it is easier to read and to maintain.
