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

8.9. Labs

In this chapter we’re going to build on the functions you created in the last chapter using the concepts you hopefully picked up today. As you work through these labs, add verbose messages to display key steps or progress information.

8.9.1. Lab A

Modify your advanced function from chapter 7, Lab A, to accept pipeline input for the –ComputerName parameter. Also, add verbose input that will display the name of each computer contacted. Include code to verify that the –ComputerName parameter will not accept a null or empty value. Test the function by adding 'localhost' | <function-name> -verbose to the end of your script. The output should look something like this:

VERBOSE: Starting Get-Computerdata VERBOSE: Getting data from localhost ...

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