Working with modules
Back in Chapter 2, Exploring PowerShell Cmdlets and Syntax, we spent some time exploring how we can use modules to find new cmdlets. In this chapter, we’ll be writing modules, but first, let’s recap what we learned previously and place it in some sort of context.
Modules allow us to reuse and distribute code so that it can be easily automated by including the cmdlets that manipulate modules in our scripts. So, if we need a cmdlet from the PowerShell math module in our script, then we can programmatically import that module (or just the required cmdlet) and use it. We can do this in a predictable and controllable fashion, without user intervention.
Modules fulfill three basic functions:
- Configuring the environment: They provide a repeatable custom work environment – for example, the PowerShell module for Exchange, as well as Exchange-specific cmdlets – configuring the PowerShell environment to work in a particular way with...