Minimal PowerShell module template with build, test, and docs automation.
Invoke-Buildpipeline (.build.ps1)- Module packaging with
ModuleBuilder(Source/ModuleBuilder.ps1) - Pester tests (
Tests/) - Markdown help generation with
platyPS(Docs/)
- PowerShell 5.1+ (PowerShell 7 recommended)
- PowerShellGet access to install modules
From repo root:
.\Install-Requirements.ps1This installs required modules using min/max version ranges:
ModuleBuilder(3.1.8 - 4.x)Pester(3.4.0 - 5.x)InvokeBuild(5.14.23 - 6.x)platyPS(0.14.2 - 1.x)
Run full pipeline:
Invoke-BuildDefault task order:
CheckGitStatus(expectsmainbranch)BuildModuleModuleImportGenerateMarkdownDocsRunTests
Invoke-Build CheckGitStatus
Invoke-Build BuildModule
Invoke-Build ModuleImport
Invoke-Build GenerateMarkdownDocs
Invoke-Build RunTestsSource/- module source (.psm1,.psd1,Public/,Private/)Output/- built module artifactTests/- Pester testsDocs/- generated markdown helpBuild/- shared build helper functions
- Add/modify functions in
Source/PublicorSource/Private - Add/update tests in
Tests - Run
Invoke-Build - Import built module from
Output/NewModule
When creating a new module from this template, update these first:
- Module manifest:
Source/NewModule.psd1RootModule,ModuleVersion,GUIDAuthor,CompanyName,DescriptionTags,ProjectUri,LicenseUriFunctionsToExport/CmdletsToExport/AliasesToExport
- Module file name(s)
- Rename
Source/NewModule.psm1andSource/NewModule.psd1to your module name - Keep manifest
RootModulealigned with the.psm1file name
- Rename
- Tests
- Replace sample tests in
Tests/ - Update any hardcoded module import path/name references
- Replace sample tests in
- Build defaults
- If your default branch is not
main, updateCheckGitStatusin.build.ps1
- If your default branch is not
- Dependencies
- Adjust module version policy in
Install-Requirements.ps1(minimum/maximum ranges)
- Adjust module version policy in
- Documentation
- Replace sample function help with your own comment-based help in
Source/Public/*.ps1 - Regenerate markdown docs via
Invoke-Build GenerateMarkdownDocs
- Replace sample function help with your own comment-based help in
- README metadata
- Update project name, usage examples, and links in this file
Source/ModuleBuilder.ps1builds from source manifest and writes toOutput/<ModuleName>.- Markdown help generation depends on
ModuleImportbuild task so the module name is available during docs generation.