Building PowerShell Modules
Building PowerShell Modules
Minimum price
Suggested price
Building PowerShell Modules

This book is 35% complete

Last updated on 2020-02-10

About the Book


Are you a PowerShell scripter who wishes to take their skills to the next level? Have you ever wanted to create an open-source PowerShell module but didn't' know where to start? Then this book is for you!

Whether you are creating internal modules for your organization to use or open-source modules for the community to enjoy, you'll find something valuable in this book. This is not a "how to learn PowerShell" book. It is expected you already have the basics of PowerShell down, so things like PowerShell semantics and language features will not be the topic of this book. There are already some excellent books out there that cover the PowerShell language itself. I'd encourage you to take a look at those books first if you're interested in learning more about PowerShell as a language. Consider this book a follow-up to them where you will learn how to create useful, high-quality, and engaging PowerShell modules with real-world guidance, examples, and concept discussion.

This is an Agile-published book

Updates will be published as they are written. As PowerShell module practices evolve, so to will this book. Your one-time purchase grants you lifetime access to updates and any new content. You can even get notified via Leanpub (if you opt-in) when there's new content available, so you're always up to date.

Book Pricing

As significant parts of the book are published, the price will increase accordingly. If you've already purchased a copy, then you're all set! You won't have to pay another dime, and you'll receive any updates for free. This is an excellent reason to purchase it now before it's finished to lock in the lower price.

Book Parts

The book will include four separate parts to cover high-level concepts. Each part will consist of dedicated topic chapters relevant to that concept.

  • Part 1 - Modules Primer
  • Part 2 - Project and Module Design
  • Part 3 - The Build and Test Loop
  • Part 4 - Creating a Quality Community Project


I love feedback. Use the "Email the Author(s)" link below to contact me. If something is unclear or you feel it is flat out wrong, let me know. All constructive feedback is welcome and ultimately creates a better book for everyone.

About the Author

Brandon Olin
Brandon Olin

Brandon is a Site Reliability Engineer, Cloud Architect, veteran Systems Engineer, speaker, blogger, freelance writer, and open source contributor. He is a Microsoft MVP in Cloud and Datacenter Management and has a penchant for PowerShell and DevOps processes. He spends much of his time exploring new technologies to drive the business forward and loves to apply ideas pioneered in the DevOps community to solving real-world business problems. Brandon is active in the PowerShell community and loves to give back with a number of projects published to the PowerShell Gallery.

You can follow his code at GitHub, his blog at, or reach him on Twitter at @devblackops.

Reader Testimonials

Jim Birley
Jim Birley

It truly is a book that fills a long-standing gap in topics from other PowerShell books. I have been asking other people for good material on module development for quite some time. This book is it.

Table of Contents

    • About the Author
    • About This Book
      • PowerShell version
      • Roadmap
        • Part 1
        • Part 2
        • Part 3
        • Part 4
    • Feedback
    • Typographic Conventions
      • Asides
    • Dedication
    • Introduction
  • Part 1 - Modules Primer
    • 1 Module Basics
      • 1.1 What is a module
      • 1.2 Why build modules
        • 1.2.1 Organizing related functionality
        • 1.2.2 Code sharing
        • 1.2.3 Code reuse
        • 1.2.4 Versioning
      • 1.3 Terminology
      • 1.4 Module types
        • 1.4.1 Script modules
        • 1.4.2 Binary modules
        • 1.4.3 Manifest
        • 1.4.4 What is a manifest
      • 1.5 Summary
    • 2 Working with Modules
      • 2.1 Module locations
        • 2.1.1 $env:PSModulePath
      • 2.2 PowerShellGet
        • 2.2.1 Finding modules online
        • 2.2.2 Installing a module
        • 2.2.3 Updating modules
        • 2.2.4 Uninstalling modules
      • 2.3 Discovering module information
        • 2.3.1 Listing installed modules
        • 2.3.2 Getting module commands
        • 2.3.3 Exploring a module
      • 2.4 Installing modules
        • 2.4.1 Creating a hello world module
        • 2.4.2 Manual installation
        • 2.4.3 PowerShellGet
      • 2.5 Saving modules
      • 2.6 Importing modules
        • 2.6.1 Modules are single-instance
        • 2.6.2 Module prefixes
      • 2.7 Being specific with module specifications
      • 2.8 Module auto-loading
        • 2.8.1 Controlling auto-loading behavior
      • 2.9 Removing modules
        • 2.9.1 Removing a module by name
        • 2.9.2 Removing a module by using a module specification
        • 2.9.3 Removing a module by PSModuleInfo
        • 2.9.4 Caveats
      • 2.10 Summary
    • 3 Authoring a Module
      • 3.1 Basic structure of a module
        • 3.1.1 Rules and conventions for module files
        • 3.1.2 Exceptions to the rules
      • 3.2 Creating a script module
        • 3.2.1 Creating a basic script
        • 3.2.2 Turning a script into a module
      • 3.3 Manifests
        • 3.3.1 Manifest structure
        • 3.3.2 Creating a module manifest
        • 3.3.3 Elements of a manifest
        • 3.3.4 Updating a manifest
        • 3.3.5 Testing a manifest
      • 3.4 Summary
    • 4 Dealing with Module Dependencies
      • 4.1 Module dependencies
        • 4.1.1 Implicit dependencies
        • 4.1.2 Explicit dependencies
        • 4.1.3 Focusing our efforts
        • 4.1.4 Defining dependencies to other modules
        • 4.1.5 Installing dependencies
      • 4.2 Summary
    • 5 Distributing Modules
      • 5.1 PowerShell repositories
        • 5.1.1 The default repository
        • 5.1.2 Trusting repositories
        • 5.1.3 Repository types
      • 5.2 Creating a local repository
        • 5.2.1 Registering a repository
      • 5.3 Publishing a module locally
        • 5.3.1 Publishing a module by name
        • 5.3.2 Publishing a module by file path
      • 5.4 The PowerShell Gallery, a tour
        • 5.4.1 Navigating the Gallery
        • 5.4.2 Registering on the Gallery
        • 5.4.3 Managing API keys
      • 5.5 Summary
  • Part 2 - Project and Module Design
    • 6 Choosing a Module Layout
      • 6.1 Monolithic PSM1
        • 6.1.1 Module structure
      • 6.2 Category submodules
        • 6.2.1 Grouping by domain
      • 6.3 Dot-sourced functions from PSM1
        • 6.3.1 What happens during import
        • 6.3.2 Advantages and disadvantages
      • 6.4 Final verdict
      • 6.5 Summary
    • 7 Keeping Some Module Contents Private
      • 7.1 Determining the public functions
        • 7.1.1 The role of private functions
        • 7.1.2 Candidates for private functions
        • 7.1.3 Controlling the visibility of variables and aliases
      • 7.2 Summary
    • 9 Building a Module From Many Files
    • 10 Versioning a Module
    • 11 Building Better Commands
    • 12 Elements of a Quality GitHub Project
    • 13 Documenting a Project
  • Part 3 - The Build and Test Loop
  • Part 4 - Creating a Quality Community Project

Other books by this author

Authors have earned$8,524,644writing, publishing and selling on Leanpub,
earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub