WEBVTT

00:03.080 --> 00:04.580
Scenario for the lab.

00:04.700 --> 00:09.470
Moving from script to function to module, you have written the following script.

00:10.370 --> 00:15.350
You now want to convert that script to a function in preparation for packaging the script as a script

00:15.350 --> 00:15.890
module.

00:16.760 --> 00:19.340
The main tasks for this exercise are as follows.

00:20.240 --> 00:24.890
One Add the function declaration to execute the function.

00:25.760 --> 00:28.490
Three Test the script task.

00:28.490 --> 00:30.470
One Add the function declaration.

00:31.340 --> 00:34.790
One in the Windows PowerShell, ISC or another editor.

00:34.790 --> 00:42.650
Edit the above script which can be named Exercise one Task 1.1 to wrap all the contents of the script

00:42.650 --> 00:44.540
in a function named get disk info.

00:45.410 --> 00:54.980
Three Save the script as c colon backslash tools dot PS1 task to execute the function one in your toolkit.

00:54.980 --> 00:58.190
PS one script add the following to the end of the script.

00:59.060 --> 01:01.220
Get disk info comp local host.

01:02.120 --> 01:07.430
This command will execute the function when you run the script to save the script.

01:08.300 --> 01:10.130
Task three Test the script.

01:11.030 --> 01:14.780
Run your tools dot PS one Script results.

01:14.900 --> 01:21.170
After completing this exercise, you will have converted the code in your script into a function scenario

01:21.170 --> 01:22.040
for the lab.

01:22.160 --> 01:28.850
Moving from script to function to module exercise two You have written the following script.

01:29.750 --> 01:33.410
You have to package this script as a Windows PowerShell script module.

01:34.270 --> 01:36.880
The main tasks for this exercise are as follows.

01:37.750 --> 01:38.230
One.

01:38.290 --> 01:43.000
Remove the function call to save the script as a script module.

01:43.910 --> 01:44.450
Three.

01:44.480 --> 01:45.860
Test the script module.

01:46.670 --> 01:47.480
Task one.

01:47.570 --> 01:48.590
Remove the function.

01:48.590 --> 01:50.330
Call one.

01:50.420 --> 01:56.780
Continuing on from the last exercise in your C colon backslash tools dot ps one script remove the line

01:56.780 --> 02:00.110
that runs the git disk info function because it is no longer needed.

02:01.010 --> 02:06.560
This should be the last line in your script to save the script task.

02:06.560 --> 02:09.020
To save the script as a script module.

02:09.920 --> 02:15.860
Save your tools dot PS one script as a script module named My Tools Task three.

02:15.890 --> 02:24.500
Test the script module one in the Windows PowerShell ISC Switch to the console pane to run the get disk

02:24.500 --> 02:25.370
info command.

02:26.290 --> 02:28.720
Specify local host as the computer name.

02:29.590 --> 02:30.110
Three.

02:30.130 --> 02:33.910
Remove the my tools module from memory results.

02:34.030 --> 02:38.320
After completing this exercise, you will have saved your script as a script module.

02:39.160 --> 02:44.380
Exercise three scenario You have created a script module named My Tools.

02:45.220 --> 02:49.330
In this exercise, you will add debugging breakpoints to the script module.

02:50.200 --> 02:59.380
The main tasks for this exercise are as follows one at a breakpoint to test the script module task one

02:59.380 --> 03:06.800
at a breakpoint, one continuing on from the previous exercise in your my tools dot PSM one script add

03:06.820 --> 03:10.120
a debugging breakpoint on the line after the write verbose command.

03:10.960 --> 03:17.320
The debug output should include the computer name that the function is about to query to save the script

03:17.320 --> 03:27.070
module task to test the script module one in the Windows PowerShell A-Z switch to the console pane to

03:27.190 --> 03:29.020
run the get disk info command.

03:29.920 --> 03:33.910
Specify local host as the computer name and do not enable debugging.

03:34.780 --> 03:37.180
Three Run the get disk info command.

03:38.110 --> 03:41.770
Specify local host as the computer name and enable debugging.

03:42.640 --> 03:44.350
Four at the debug prompt.

03:44.350 --> 03:45.430
Suspend the script.

03:46.330 --> 03:46.810
Five.

03:46.960 --> 03:49.390
Display the contents of dollar computer name.

03:50.230 --> 03:50.770
Six.

03:51.070 --> 03:52.360
Exit debug mode.

03:53.230 --> 03:53.770
Seven.

03:54.040 --> 03:55.450
Let the command continue.

03:56.260 --> 03:56.590
Eight.

03:56.830 --> 04:00.640
Remove the My Tools module from memory results.

04:00.790 --> 04:06.370
After completing this exercise, you will have added debugging breakpoints to the mutual script module.
