Skip to main content

PSScriptAnalyzer

Official module: dagger/PsScriptAnalyzer

Install with dagger mod install github.com/dagger/PsScriptAnalyzer.

What It Is​

The PSScriptAnalyzer module checks PowerShell scripts with PSScriptAnalyzer.

Use it when PowerShell is part of the project and needs the same review bar as application code.

Use It For​

  • Check PowerShell scripts in CI and Dagger Cloud.
  • Enforce style, safety, and ruleset expectations.
  • Include supporting files when scripts need project context.

Main Workflow​

  • check: run PSScriptAnalyzer on discovered PowerShell scripts.

How to Use It​

Install the module, then run its check. The module's workspace alias is ps-analyzer, so its check and settings use that name:

dagger mod install github.com/dagger/PsScriptAnalyzer

dagger check # run every check in the workspace
dagger check ps-analyzer:check # run PSScriptAnalyzer on discovered PowerShell scripts

check finds every .ps1, .psm1, and .psd1 file in the workspace and runs Invoke-ScriptAnalyzer recursively, failing on any diagnostic it reports.

Settings​

List the current settings and their values with dagger settings ps-analyzer, then set one with dagger settings ps-analyzer <key> <value>. Settings are stored in .dagger/config.toml under [modules.ps-analyzer.settings].

  • version (default 1.22.0): the PSScriptAnalyzer release to install. Pin it so the same ruleset and analyzer behavior run locally and in CI.
  • exclude (default: none): a list of script paths to skip.
  • includeExtraFiles (default empty): extra non-PowerShell paths to mount, for scripts that read data files or other project context during analysis.
dagger settings ps-analyzer version 1.22.0

The list-valued settings are edited directly in .dagger/config.toml:

[modules.ps-analyzer.settings]
version = "1.22.0"
exclude = ["tests/"]
includeExtraFiles = ["data/"]

Workspace Fit​

Use this module for repos with PowerShell automation, Windows support scripts, or PowerShell modules. It complements ShellCheck in mixed shell workspaces.

Source​

Source repo: github.com/dagger/PsScriptAnalyzer