Getting Started¶
Create, validate, trust and run your first policy.
Installation¶
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:
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"
- Editors with YAML support can use this schema for validation and autocompletion.
Validation¶
Trust¶
Review the policy and trust it:
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:
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'
Related¶
-
Continuous evaluation and
--dry-run. -
Match processes, windows, time and command results.
-
Run commands when a rule matches.
-
Detect modifications of policies and scripts.