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 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.
We’ll present our solution in progressively more complete steps. When we’ve finished, we’ll provide a formal, numbered listing that has the final product. If you’re eager to just see the end result, skip ahead to listing 32.1.
Additional steps are required to finalize the module, shown in listings 32.2 to 32.4.