11# PSScriptModule.Template
22
3- A production-ready PowerShell script module template designed to streamline the creation, testing, and delivery of enterprise-grade PowerShell modules. This template implements modern DevOps practices, automated quality gates, and continuous delivery workflows right out of the box.
3+ A production-ready PowerShell script module template designed to streamline the creation, testing, and delivery of enterprise-grade PowerShell modules. This template implements modern DevOps practices,
4+ automated quality gates, and continuous delivery workflows right out of the box.
45
56[ ![ CI] ( https://github.com/WarehouseFinds/PSScriptModule/actions/workflows/ci.yml/badge.svg )] ( https://github.com/WarehouseFinds/PSScriptModule/actions/workflows/ci.yml )
67[ ![ PowerShell Gallery] ( https://img.shields.io/powershellgallery/v/PSScriptModule.svg )] ( https://www.powershellgallery.com/packages/PSScriptModule )
7- [ ![ License] ( https://img.shields.io/github/license/WarehouseFinds/PSScriptModule.Template )] ( LICENSE )
8+ [ ![ License] ( https://img.shields.io/github/license/WarehouseFinds/PSScriptModule )] ( LICENSE )
89
910## 🎯 Purpose
1011
11- This template solves the common challenge of setting up a professional PowerShell module project from scratch. Instead of manually configuring build scripts, testing frameworks, and CI/CD pipelines, you can clone this repository and start writing your module's business logic immediately.
12+ This template solves the common challenge of setting up a professional PowerShell module project from scratch. Instead of manually configuring build scripts, testing frameworks, and CI/CD pipelines,
13+ you can clone this repository and start writing your module's business logic immediately.
1214
1315** Perfect for:**
14- - 🏢 Enterprise PowerShell module development
16+
1517- 📦 Open-source PowerShell projects
1618- 🔧 DevOps automation tools
1719- 🎓 Learning PowerShell module development best practices
1820
21+ ## How to Use This Template
22+
23+ Simply copy the template to your account, then give bootstrap action ** about 20 seconds** to prepare the repository for you, then ** refresh the page** .
24+ The name and description will be automatically set based on your inputs.
25+
26+ [ ![ ] ( https://img.shields.io/badge/Copy%20Powershell%20Module-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935 )] ( https://github.com/new?template_owner=WarehouseFinds&template_name=PSScriptModule&owner=%40me&name=PS-&description=PS%20Module%20Template&visibility=public )
27+
1928## ✨ Key Features
2029
2130### 🏗️ Structured Project Layout
31+
2232- ** Clear separation of concerns** with dedicated folders for source code, tests, and documentation
2333- ** Public/Private function organization** for proper encapsulation
2434- ** Module manifest (` .psd1 ` )** with all necessary metadata
2535- ** Standardized naming conventions** for consistency
2636
2737### 🔨 Automated Build System
38+
2839- ** Invoke-Build orchestration** with predefined build tasks
2940- ** ModuleBuilder integration** for compiling script modules
3041- ** Automated module packaging** ready for distribution
3142- ** Debug and Release configurations** for different build scenarios
3243
3344### 🧪 Comprehensive Testing
45+
3446- ** Pester 5+ testing framework** for unit tests
3547- ** Code coverage reporting** (Cobertura format)
3648- ** PSScriptAnalyzer integration** for static code analysis
@@ -39,18 +51,21 @@ This template solves the common challenge of setting up a professional PowerShel
3951- ** Test results in NUnit XML format** for CI/CD integration
4052
4153### 📚 Documentation Generation
54+
4255- ** PlatyPS integration** for markdown-based help
4356- ** Automated MAML generation** for Get-Help support
4457- ** External help files** (` .xml ` ) for PowerShell's built-in help system
4558- ** Example-driven documentation** templates
4659
4760### 🔄 Automated Versioning
61+
4862- ** GitVersion** for semantic versioning based on git history
4963- ** GitHub Flow workflow** for streamlined releases
5064- ** Commit-based version control** using ` +semver: ` keywords
5165- ** Automatic version updates** in module manifest
5266
5367### 🚀 CI/CD Ready
68+
5469- ** Pre-configured GitHub Actions** workflows
5570- ** Automated quality gates** (tests, analysis, security scans)
5671- ** Automated releases** on PR merges to main
@@ -59,13 +74,14 @@ This template solves the common challenge of setting up a professional PowerShel
5974- ** Manual workflow dispatch** with version control and publishing options
6075
6176### 📦 Dependency Management
77+
6278- ** PSDepend** for managing module dependencies
6379- ** Version-pinned dependencies** for reproducible builds
6480- ** Automatic dependency installation** in CI/CD pipelines
6581
6682## 📂 Project Structure
6783
68- ```
84+ ``` plaintext
6985PSScriptModule.Template/
7086├── 📄 PSScriptModule.build.ps1 # Invoke-Build script with all build tasks
7187├── 📄 requirements.psd1 # PSDepend configuration for dependencies
@@ -105,12 +121,14 @@ PSScriptModule.Template/
105121### Quick Start
106122
1071231 . ** Clone or use this template:**
124+
108125 ``` bash
109126 git clone https://github.com/WarehouseFinds/PSScriptModule.Template.git MyModule
110127 cd MyModule
111128 ```
112129
1131302 . ** Install dependencies:**
131+
114132 ``` powershell
115133 # Install PSDepend if not already installed
116134 Install-Module -Name PSDepend -Scope CurrentUser -Force
@@ -120,11 +138,13 @@ PSScriptModule.Template/
120138 ```
121139
1221403 . ** Customize the module:**
141+
123142 - Update ` src/PSScriptModule.psd1 ` with your module information
124143 - Rename files and folders from ` PSScriptModule ` to your module name
125144 - Add your functions to ` src/Public/ ` and ` src/Private/ `
126145
1271464 . ** Build and test:**
147+
128148 ``` powershell
129149 # Run default build (Clean + Build)
130150 Invoke-Build
@@ -185,6 +205,7 @@ Invoke-Pester -Configuration @{
185205### Test Output
186206
187207All test results are saved to ` test-results/ ` directory:
208+
188209- ` unit-tests.xml ` - Pester test results (NUnit XML)
189210- ` code-coverage.xml ` - Code coverage report (Cobertura)
190211- ` static-code-analysis.xml ` - PSScriptAnalyzer results
@@ -200,6 +221,7 @@ Invoke-Build Export-CommandHelp
200221```
201222
202223Help files are generated in two formats:
224+
2032251 . ** Markdown** (` .md ` ) - Stored in ` docs/help/ ` for web/GitHub viewing
2042262 . ** MAML** (` .xml ` ) - Stored in module's ` en-US/ ` folder for ` Get-Help ` command
205227
@@ -242,7 +264,7 @@ The CI workflow orchestrates multiple jobs in parallel:
242264The pipeline automatically determines the build type:
243265
244266| Event | Build Type | Version Format | Published |
245- | -------| ----------- | ----------------| ----------- |
267+ | --------- | ---------------- | --------- |
246268| Pull Request | Debug | ` 1.2.3-PullRequest1234 ` | No |
247269| Push to main | Prerelease | ` 1.2.3-Prerelease ` | Yes |
248270| Manual (workflow_dispatch) | Release | ` 1.2.3 ` | Optional |
@@ -262,7 +284,7 @@ This template uses **Semantic Versioning** (SemVer) with automated version manag
262284Include one of these keywords in your commit message:
263285
264286| Keyword | Version Change | Example |
265- | ---------| ----------------| ---------|
287+ | --------- | ---------------- | --------- |
266288| ` +semver: breaking ` or ` +semver: major ` | Major (1.0.0 → 2.0.0) | Breaking changes |
267289| ` +semver: feature ` or ` +semver: minor ` | Minor (1.0.0 → 1.1.0) | New features |
268290| ` +semver: fix ` or ` +semver: patch ` | Patch (1.0.0 → 1.0.1) | Bug fixes |
@@ -282,6 +304,7 @@ git commit -m "Update README +semver: none"
282304### Creating New Functions
283305
2843061 . ** Create function file** in ` src/Public/ ` or ` src/Private/ ` :
307+
285308 ``` powershell
286309 # src/Public/Get-Something.ps1
287310 function Get-Something {
@@ -310,6 +333,7 @@ git commit -m "Update README +semver: none"
310333 ```
311334
3123352 . ** Create test file** alongside function:
336+
313337 ``` powershell
314338 # src/Public/Get-Something.Tests.ps1
315339 BeforeAll {
@@ -325,12 +349,14 @@ git commit -m "Update README +semver: none"
325349 ```
326350
3273513 . ** Update module manifest** if adding public function:
352+
328353 ``` powershell
329354 # Add to FunctionsToExport in PSScriptModule.psd1
330355 FunctionsToExport = @('Get-PSScriptModuleInfo', 'Get-Something')
331356 ```
332357
3333584 . ** Build and test** :
359+
334360 ``` powershell
335361 Invoke-Build Test
336362 ```
@@ -355,6 +381,7 @@ Invoke-Build -ReleaseType Release -NugetApiKey 'YOUR-API-KEY'
355381### Automated Publishing (CI/CD)
356382
357383Configure your GitHub repository secrets:
384+
358385- ` NUGETAPIKEY_PSGALLERY ` - Your PowerShell Gallery API key
359386
360387The CI/CD pipeline will automatically publish on release.
@@ -364,19 +391,21 @@ The CI/CD pipeline will automatically publish on release.
364391You can manually trigger builds and releases via GitHub Actions workflow dispatch:
365392
3663931 . ** Navigate to Actions** → CI workflow
367- 2 . ** Click "Run workflow"**
394+ 2 . ** Click "Run workflow"**
3683953 . ** Configure options** :
369396 - ` version-tag ` : Specify a version tag to build (e.g., ` v0.9.7 ` ) - leave empty to use current commit
370397 - ` publish ` : Check to publish the release to PowerShell Gallery
371398
372399This is useful for:
400+
373401- Creating releases from specific commits or tags
374402- Re-publishing existing versions
375403- Testing release workflows before merging to main
376404
377405## 🤝 Contributing
378406
379407We welcome contributions! Please see our [ CONTRIBUTING.md] ( CONTRIBUTING.md ) guide for:
408+
380409- How to report issues
381410- Pull request process
382411- Code style guidelines
@@ -385,6 +414,7 @@ We welcome contributions! Please see our [CONTRIBUTING.md](CONTRIBUTING.md) guid
385414## 🤖 AI Agent Support
386415
387416This repository includes special documentation for AI coding assistants. See [ AGENTS.md] ( AGENTS.md ) for:
417+
388418- Project structure and conventions
389419- Function templates and patterns
390420- Testing guidelines
@@ -395,7 +425,7 @@ This repository includes special documentation for AI coding assistants. See [AG
395425This template uses the following PowerShell modules:
396426
397427| Module | Version | Purpose |
398- | --------| ---------| ---------|
428+ | --------- | ---------------- | --------- |
399429| ** InvokeBuild** | 5.14.22 | Build orchestration |
400430| ** ModuleBuilder** | 3.1.8 | Module compilation |
401431| ** Pester** | 5.7.1 | Testing framework |
@@ -414,6 +444,7 @@ This project is licensed under the terms specified in the [LICENSE](LICENSE) fil
414444### PSScriptAnalyzer Integration
415445
416446Enforces PowerShell best practices and catches common mistakes:
447+
417448- Cmdlet design rules
418449- Performance optimizations
419450- Security best practices
@@ -422,6 +453,7 @@ Enforces PowerShell best practices and catches common mistakes:
422453### InjectionHunter Security
423454
424455Scans for common injection vulnerabilities:
456+
425457- Command injection risks
426458- Script injection patterns
427459- Unsafe variable usage
@@ -430,6 +462,7 @@ Scans for common injection vulnerabilities:
430462### ModuleBuilder
431463
432464Compiles your script module:
465+
433466- Combines all ` .ps1 ` files into single ` .psm1 `
434467- Updates module version automatically
435468- Copies required files to output
@@ -438,6 +471,7 @@ Compiles your script module:
438471### PlatyPS Documentation
439472
440473Generates professional documentation:
474+
441475- Markdown help files for each command
442476- MAML files for PowerShell's Get-Help
443477- Module-level documentation
@@ -446,6 +480,7 @@ Generates professional documentation:
446480### CodeQL Semantic Analysis
447481
448482Advanced security scanning with GitHub CodeQL:
483+
449484- Runs weekly on a schedule
450485- Integrates with GitHub Security tab
451486- Detects complex security vulnerabilities
@@ -454,11 +489,12 @@ Advanced security scanning with GitHub CodeQL:
454489### Automated Maintenance Workflows
455490
456491Keep your repository clean with automated maintenance:
492+
457493- ** Artifact Cleanup** : Automatically removes artifacts older than 2 days (configurable)
458494- ** Workflow Run Cleanup** : Removes old workflow runs to keep history manageable
459- - Configurable retention period (default: 2 days)
460- - Configurable minimum runs to keep (default: 2)
461- - Separate cleanup for pull requests, pushes, and scheduled runs
495+ - Configurable retention period (default: 2 days)
496+ - Configurable minimum runs to keep (default: 2)
497+ - Separate cleanup for pull requests, pushes, and scheduled runs
462498- Runs daily at midnight via cron schedule
463499- Can be triggered manually with custom parameters
464500
@@ -478,4 +514,4 @@ Keep your repository clean with automated maintenance:
478514
479515---
480516
481- ** Built with ❤️ by [ Warehouse Finds] ( https://github.com/WarehouseFinds ) **
517+ ** Built with ❤️ by [ Warehouse Finds] ( https://github.com/WarehouseFinds ) **
0 commit comments