A module with helper functions to build and publish PowerShell modules to the PSGallery.
Install-Module PSModuleUtils
Follow The PowerShell Best Practices and Style Guide as much as possible, with the following rules being the most important:
- Use Approved Verbs for commands so that PowerShell's built-in ability to autocomplete un-imported functions works.
- Add help comments to all functions because each module's wiki is auto-generated from them.
Use the following additional guidelines:
- The module file itself (
.psm1
) should not contain any functions or logic, in most cases, other than aforeach
loop to dot source all the.ps1
files andNew-Alias
statements for specific functions. - Ideally, each module and each of its functions should have a set of Pester unit/integration tests. At the least, any new functions or functionality should have an associated test.
- Create all functions as single
.ps1
files with the same name and withoutExport-ModuleMember
statements.- The files should be in an appropriate nested
Public
folder that corresponds to its API category. - Functions that are used by other functions should be put in either
Utils
orPrivate
, depending on their usage.
- The files should be in an appropriate nested
- The module file (
.psm1
) and each function should have a corresponding.Tests.ps1
file containing Pester unit/integration tests. - Don't change any documentation or manifest files; they are automatically populated by the pipeline.
The folder structure should be maintained like the example below:
\MODULEREPODIRECTORY
├───.github
│ └───workflows
├───.gitignore
├───LICENSE
├───README.md
│
└───src
├───ModuleName.Module.Tests.ps1
├───ModuleName.psm1
│
public
├───functionalArea
│ ├───Verb-Noun.ps1
│ └───Verb-Noun.Tests.ps1
│
private
├───Verb-Noun.ps1
└───Verb-Noun.Tests.ps1