Validate a module manifest
Documentation: Microsoft Learn
Get-ChildItem finds every psd1 file under the current directory and ForEach-Object runs Test-ModuleManifest against each full path.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-ChildItem . -Filter *.psd1 -Recurse | ForEach-Object { Test-ModuleManifest $_.FullName | Select-Object Name,Version,PowerShellVersion,CompatiblePSEditions }- Stage 1Get-ChildItem
-Filter -Recurse - Stage 2ForEach-Object
Positional values or no named parameters
How it works
Get-ChildItem finds every psd1 file under the current directory and ForEach-Object runs Test-ModuleManifest against each full path. The projection reports the module name and version alongside the required PowerShell version and the editions the manifest claims to support.
Adapting it
Assert the reported version against the build number and throw when they diverge, which turns an informational listing into a gate that stops a bad release.
If the result is unexpected
A module manifest fails validation on another host.
Referenced files, dependency versions and compatible editions may differ from the development machine.
- Run validation from the packaged module location and inspect the first reported dependency or path failure.
Validate the result
The packaged manifest validates with its actual files and supported runtime.
Keep the check reliable
Validate the packaged artifact in the target runtime in addition to validating the source folder.