O'Reilly logo

Learn PowerShell Toolmaking in a Month of Lunches by Don Jones and Jeffrey Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.8. Labs

You are going to continue with the functions you’ve been building the last few chapters. The next step is to begin incorporating some error handling using Try...Catch...Finally. If you haven’t done so, take a few minutes to read the help content on Try...Catch...Finally. For any changes you make, don’t forget to update your comment-based help.

10.8.1. Lab A

Using Lab A from chapter 9, add a –ErrorLog parameter to your advanced function, which accepts a filename for an error log and defaults to C:\Errors.txt. When the function is run with this parameter, failed computer names should be appended to the error log file.

Next, if the first WMI query fails, the function should output nothing for that computer and should not attempt a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required