Chapter 4. Simple scripts and functions
Depending on how much you’ve worked with PowerShell already, this chapter may be a bit of a refresher. That’s okay, because we’re going to quickly build on what this chapter covers. In fact, you can think of this chapter as your true starting point in tool-making, now that we’ve reviewed some of the foundation topics. This chapter represents the point where tool users usually stop and where true tool maker begins.
Whenever we set out to build a tool, we usually start at the shell’s command line. Internally, tools run PowerShell commands in a specific sequence, so we’ll start by getting our command working properly. After all, at the command line we have less complication to worry about and fewer moving parts. It’s a lot easier to get the command working there and to then move it into a script than to start in a script where many other things are going on. Start simple and then build complexity!
For this chapter, we’ll start with a simple tool that retrieves some basic operating system information from a remote computer. Here’s the command, along with a sample of its output: