PowerShell Release Automation
Release automation is a script that prepares a new version for shipping. It stamps the version number into the module manifest and writes a changelog file.
Read the current version from a manifest
The manifest is a file the script created. Reading it shows the current version.
Set-Content -Path (Join-Path $PSScriptRoot "Tools.psd1") -Value '@{ ModuleVersion = "1.0.0" }'
$data = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot "Tools.psd1")
$data.ModuleVersionStamp a new version into the manifest
Writing the manifest again with a new number stamps the new version. Reading it back proves the stamp.
Set-Content -Path (Join-Path $PSScriptRoot "Tools.psd1") -Value '@{ ModuleVersion = "1.0.0" }'
Set-Content -Path (Join-Path $PSScriptRoot "Tools.psd1") -Value '@{ ModuleVersion = "1.1.0" }'
$data = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot "Tools.psd1")
$data.ModuleVersionWrite a changelog entry with a fixed date
The changelog lists the new version and what changed. The date is a fixed literal, so the entry never changes.
$date = Get-Date -Date "2026-10-28" -Format "yyyy-MM-dd"
Set-Content -Path (Join-Path $PSScriptRoot "CHANGELOG.txt") -Value @("## 1.1.0 - $date", "- Added the greeting tool")
Get-Content -Path (Join-Path $PSScriptRoot "CHANGELOG.txt")Example
Set-Content -Path (Join-Path $PSScriptRoot "Tools.psd1") -Value '@{ ModuleVersion = "1.0.0" }'
Set-Content -Path (Join-Path $PSScriptRoot "Tools.psd1") -Value '@{ ModuleVersion = "1.2.0" }'
$data = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot "Tools.psd1")
$data.ModuleVersion
$date = Get-Date -Date "2026-10-28" -Format "yyyy-MM-dd"
Set-Content -Path (Join-Path $PSScriptRoot "CHANGELOG.txt") -Value @("## 1.2.0 - $date", "- Added the greeting tool")
Get-Content -Path (Join-Path $PSScriptRoot "CHANGELOG.txt")Key points
- Manifest: a file that describes a module, including its version number.
- Use Import-PowerShellDataFile to read a manifest file into a variable.
- Use Set-Content to write a new version into a manifest file.
- Changelog: a file that lists what changed in each version, newest first.
- Use Get-Date with a fixed date literal to stamp a release date that never changes.
In this example, the script stamps version 1.2.0 into the manifest it created and reads it back. It then writes a changelog entry with the fixed release date and prints the entry.
Note
A release script edits only files it created or owns. It never edits a real module on disk.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does stamping a version mean?