Lab C Implementing Basic Error Handling Scenario.
You have written a Windows PowerShell script that may encounter errors when it is run in your environment.
You have to change the script to handle and log those errors.
Objectives.
After completing this lab, students will be able to implement error handling in an existing function
test error handling capabilities in a function exercise one and error handling to a function exercise
scenario.
In this exercise, you will add error handling to an existing function that you created earlier in this
module in lab.
The main tasks for this exercise are as follows.
One Add error handling to a function to test the function.
Task one Add error handling to a function one continuing on from lab open the my tools dot psm one script
that you created in lab.
At error handling so that an error in the get the AM instance command displays verbose output that contains
the name of the computer to save the script task to test the function one.
Switch to the console pane to remove the my tools module from memory three.
Run the get disk info command, specify bad for the computer name and enable verbose output results.
After completing this exercise, you will have added error handling to an existing function exercise
to add error handling to a new function.
In this exercise, you will add error handling to a function that someone else wrote.
The main tasks for this exercise are as follows.
One Identify potential error points to add error handling.
Three Test the function task.
One Identify potential error points.
One Open Exercise two Task 1.1 in the Windows PowerShell A-Z to identify the command that could cause
an error if an incorrect computer name was specified.
Three.
Run the script and notice the behavior when an incorrect computer name is specified.
Tasked to add error handling one add error handling to the exercise two task one dot piece one Script.
Your error handling must display a verbose message.
If an error happens, the message must include the name of the computer that could not be reached.
To save the script.
Task three.
Test the function.
Run the script and notice the new behavior when an incorrect computer name is specified.
Results.
After completing this exercise, you will have added error handling to a function that someone else
wrote.