Scenario for the lab.
Moving from script to function to module, you have written the following script.
You now want to convert that script to a function in preparation for packaging the script as a script
module.
The main tasks for this exercise are as follows.
One Add the function declaration to execute the function.
Three Test the script task.
One Add the function declaration.
One in the Windows PowerShell, ISC or another editor.
Edit the above script which can be named Exercise one Task 1.1 to wrap all the contents of the script
in a function named get disk info.
Three Save the script as c colon backslash tools dot PS1 task to execute the function one in your toolkit.
PS one script add the following to the end of the script.
Get disk info comp local host.
This command will execute the function when you run the script to save the script.
Task three Test the script.
Run your tools dot PS one Script results.
After completing this exercise, you will have converted the code in your script into a function scenario
for the lab.
Moving from script to function to module exercise two You have written the following script.
You have to package this script as a Windows PowerShell script module.
The main tasks for this exercise are as follows.
One.
Remove the function call to save the script as a script module.
Three.
Test the script module.
Task one.
Remove the function.
Call one.
Continuing on from the last exercise in your C colon backslash tools dot ps one script remove the line
that runs the git disk info function because it is no longer needed.
This should be the last line in your script to save the script task.
To save the script as a script module.
Save your tools dot PS one script as a script module named My Tools Task three.
Test the script module one in the Windows PowerShell ISC Switch to the console pane to run the get disk
info command.
Specify local host as the computer name.
Three.
Remove the my tools module from memory results.
After completing this exercise, you will have saved your script as a script module.
Exercise three scenario You have created a script module named My Tools.
In this exercise, you will add debugging breakpoints to the script module.
The main tasks for this exercise are as follows one at a breakpoint to test the script module task one
at a breakpoint, one continuing on from the previous exercise in your my tools dot PSM one script add
a debugging breakpoint on the line after the write verbose command.
The debug output should include the computer name that the function is about to query to save the script
module task to test the script module one in the Windows PowerShell A-Z switch to the console pane to
run the get disk info command.
Specify local host as the computer name and do not enable debugging.
Three Run the get disk info command.
Specify local host as the computer name and enable debugging.
Four at the debug prompt.
Suspend the script.
Five.
Display the contents of dollar computer name.
Six.
Exit debug mode.
Seven.
Let the command continue.
Eight.
Remove the My Tools module from memory results.
After completing this exercise, you will have added debugging breakpoints to the mutual script module.