# Modules and Tests

Package a tool as a module, check its style, and prove it works.

Updated: November 10, 2026

## [Modules](https://www.ask-codey.com/courses/powershell-in-depth/topics/powershell-modules)

1. [Your Own Module](https://www.ask-codey.com/lessons/powershell-modules) (Journeyman): A module is a folder of functions that PowerShell loads by name: the functions go in a .psm1 file, Export-ModuleMember chooses which ones others can call, New-ModuleManifest writes a .psd1 that gives the module a version and a description, and a folder on $env:PSModulePath lets PowerShell find it from anywhere.

## [Quality](https://www.ask-codey.com/courses/powershell-in-depth/topics/powershell-quality)

1. [PSScriptAnalyzer: A Second Pair of Eyes](https://www.ask-codey.com/lessons/powershell-script-analyzer) (Journeyman): Invoke-ScriptAnalyzer reads a script or a whole module without running it and lists every likely problem with its rule, severity, line and message; the rules worth knowing ask for full command names, approved verbs, singular nouns, -WhatIf on commands that change things, results instead of Write-Host and no unused variables, and a settings file or SuppressMessageAttribute sets one aside on purpose.
2. [Testing with Pester](https://www.ask-codey.com/lessons/powershell-pester) (Freelancer): A Pester test file, named something.Tests.ps1, groups checks in Describe blocks, each It block runs your code and checks one answer with Should, and Invoke-Pester runs them all in seconds, marks each one passed or failed and says what it expected and what it got; TestDrive: gives every test a throwaway folder for its files.

## [Exercise: Test Your Tool](https://www.ask-codey.com/courses/powershell-in-depth/topics/exercise-powershell-test-your-tool)

1. [Exercise: Test Your Tool](https://www.ask-codey.com/lessons/exercise-powershell-test-your-tool) (Freelancer): Give the RecipeBox module a manifest with New-ModuleManifest, then write five Pester tests that work on a copy of the recipes in TestDrive:, and a check proves they're good enough by breaking RecipeBox five ways and expecting a test to fail each time.

Source: https://www.ask-codey.com/courses/powershell-in-depth/chapters/powershell-modules-and-tests
