A starter kit for new PowerShell script modules.
This repository demonstrates how to organize a module and accomplish a few common tasks like public vs private functions, unit tests, working with classes, and more.
Tip: For a starter that contains Azure DevOps CI pipeline support, check out PowerShellCiPipelineStarterKit.
- Public and private functions.
- Unit testing with the Pester framework.
- PowerShell v5 classes (accessible inside and outside the module scope).
- Module private data (for constants and caching).
- Referencing static resource files.
- Referencing external libraries.
- Clone the repository to your local computer.
- Open PowerShell (as an administrator).
- Install the Pester framework:
Install-Module -Name Pester -MinimumVersion 4.10.1 -Scope AllUsers -Force -SkipPublisherCheck
- Add this starter kit module to the PSModule path. Note: This assumes you have cloned the repository to C:\Source. Update the path if this isn't correct.
$repoDirectory = 'C:\Source\PowerShellModuleStarterKit'
$existingPaths = $ENV:PSModulePath
$newPaths = "$repoDirectory;$existingPaths"
$scope = [System.EnvironmentVariableTarget]::Machine
[System.Environment]::SetEnvironmentVariable('PSModulePath',$newPaths,$scope)
Import-Module -Name SampleModule
Note: This assumes you have cloned the repository to C:\Source. Update the path if this isn't correct.
cd 'C:\Source\PowerShellModuleStarterKit\SampleModule'
Invoke-Pester