Chapter 32. Functions that work like cmdlets

 

This chapter covers

  • Defining a problem
  • Developing and testing a solution
  • Making the solution production ready
  • Adding formatting and type information

We’re not going to introduce any major new concepts or techniques in this chapter. Instead, we’ll use this chapter to bring together many of the things that the previous eight or so chapters covered. We’ll take a task, write a command to perform that task, and then turn that task into a complete script module, complete with error handling, debugging provisions, a custom default view, a type extension, and lots more. This example is intended to be a complete, soup-to-nuts practical illustration of something you might do on your own.

As we walk you through the various steps, pay close attention to the process we use, as well as the final result of that process. When you’re on your own, we’re obviously not going to be there with step-by-step instructions. We’ve tried, in this chapter, to document our way of thinking, and our creation process, so that you can start to adopt them as your own, enabling you to perform this same, build-it-from-scratch process for whatever tasks you need to complete.

32.1. Defining the task

32.2. Building the command

32.3. Parameterizing the pipeline

32.4. Adding professional features

32.5. Error handling

32.6. Making it a function and adding help

32.7. Creating a custom view

32.8. Creating a type extension

32.9. Making a module manifest

32.10. Summary