Remember the tool we made back in chapter 8? Well, go ahead and fire up Visual Studio Code (VS Code) and open that .ps1 file. In this chapter, we’ll take the tool you designed in chapter 8 and turn that into a reusable tool for others to use. It’s important to understand that this chapter isn’t going to attempt to have you build the entire tool or solve the entire business statement from chapter 8. We’ll take things one step at a time because it’s the process of toolmaking that we want to demonstrate for you.
Basic functions have been a part of PowerShell since day one, and they’re one of the many types of commands that PowerShell understands (some of the others being cmdlets, applications, etc.). Functions make a great unit of work for toolmaking as long as you follow the basic principle of keeping your function tightly scoped and self-contained. We’ve already written about the need to have tightly scoped functions—functions that do just one thing. Self-contained means the function needs to live in its own little world and become a kind of black box. Practically speaking, that means two things: