Skip to content

Getting Started

Create, validate, trust and run your first policy.

Installation

Requires Python 3.11 or newer.

pip install powerrules

Download the binary for your platform from the latest release.

Platform Standalone Binary
Windows 10/11 powerrules-windows-x86_64.exe
Linux powerrules-linux-x86_64
powerrules-linux-arm64
macOS powerrules-macos-arm64

Note

pwru is installed by pip. When using a standalone binary, call it by its file name instead.

Check the version:

pwru --version

Policy

Creation

Create a file named my-policy.yaml:

# yaml-language-server: $schema=https://raw.githubusercontent.com/LeoTN/PowerRules/main/assets/schema/powerrules_policy.schema.json
# (1)!
rules:
  # Match while no process named "powerrules-demo" is running
  - name: "No demo process is running"
    conditions:
      process:
        name: "powerrules-demo"
        exists: false
    actions:
      - name: "Say hello"
        run: "echo Hello from PowerRules"
  1. Editors with YAML support can use this schema for validation and autocompletion.

Validation

pwru policy validate --policy my-policy.yaml

Trust

Review the policy and trust it:

pwru trust add --policy my-policy.yaml

PowerRules refuses to run policies which are not trusted or were modified since, see Trust.

Execution

Use --once to evaluate the policy a single time:

pwru policy run --once --policy my-policy.yaml
INFO     Running policy 'my-policy.yaml' once...
INFO     Policy '/path/to/my-policy.yaml' is trusted
INFO     Running action 'Say hello'
INFO     Action 'Say hello' finished with exit code 0
INFO     Rule 'No demo process is running' matched, executed actions: 'Say hello'
  • Policy Evaluation


    Continuous evaluation and --dry-run.

  • Conditions


    Match processes, windows, time and command results.

  • Actions


    Run commands when a rule matches.

  • Trust


    Detect modifications of policies and scripts.