py-psscriptanalyzer

A Python wrapper for PSScriptAnalyzer that provides PowerShell static analysis and formatting capabilities.

Quick Start

  1. Install the package:

    pip install py-psscriptanalyzer
    
  2. Use as a pre-commit hook:

    # .pre-commit-config.yaml
    repos:
      - repo: https://github.com/thetestlabs/py-psscriptanalyzer
        rev: v0.3.1
        hooks:
          - id: py-psscriptanalyzer
          - id: py-psscriptanalyzer-format
    
  3. Or use directly from command line:

    py-psscriptanalyzer script.ps1
    py-psscriptanalyzer --format script.ps1
    

Features

  • Static Analysis: Comprehensive PowerShell code analysis using PSScriptAnalyzer

  • Code Formatting: Automatic PowerShell code formatting with Invoke-Formatter

  • Cross-Platform: Works on Windows, macOS, and Linux

  • Configurable: Customizable severity levels and rule selection

  • Fast: Efficient processing with proper error handling

  • Modern Python: Built with modern Python packaging standards

  • CI/CD Friendly - Perfect for automation pipelines

  • CLI Tool: Standalone command-line interface

  • Pre-commit Integration: Ready-to-use pre-commit hooks