O'Reilly logo

Learn PowerShell Toolmaking in a Month of Lunches by Don Jones and Jeffrey Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.4. Creating a module-level setting variable

Now that we’ve created a script module, we can take advantage of some other cool functionality provided by modules. For example, right now we’re going to create a module variable. This will work a lot like the shell’s built-in “preference” variables: The variable will be loaded into memory when the module is imported, and we’ll use it to control an aspect of the module’s behavior. The following listing shows the revised script file.

Listing 13.2. Adding a module-level variable to MOLTools.psm1

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required