microsoft/PSRule
C#
Captured source
source ↗microsoft/PSRule
Description: Validate infrastructure as code (IaC) and objects using PowerShell rules.
Language: C#
License: MIT
Stars: 468
Forks: 63
Open issues: 93
Created: 2018-03-19T09:24:17Z
Pushed: 2026-06-12T04:31:12Z
Default branch: main
Fork: no
Archived: no
README:
PSRule
A cross-platform module to validate infrastructure as code (IaC) and objects using PowerShell rules. PSRule works great and integrates with popular continuous integration (CI) systems.
Summary
- [Introduction](#summary)
- [Project Objectives](#project-objectives)
- [Support](#support)
- [Getting the module](#getting-the-module)
- [Getting extensions](#getting-extensions)
- [Getting started](#getting-started)
- [Scenarios](#scenarios)
- [Language reference](#language-reference)
- [Keywords](#keywords)
- [Commands](#commands)
- [Concepts](#concepts)
- [Schemas](#schemas)
- [Related projects](#related-projects)
- [Changes and versioning](#changes-and-versioning)
- [Contributing](#contributing)
- [Code of conduct](#code-of-conduct)
- [Maintainers](#maintainers)
- [License](#license)
Features of PSRule include
- [DevOps][2] - Built to support DevOps culture and tools.
- [Extensible][3] - Define tests using YAML, JSON, or PowerShell format.
- [Reusable][4] - Reuse and share rules across teams or organizations.
[1]: https://vscode.dev/github/microsoft/PSRule [2]: https://microsoft.github.io/PSRule/latest/features/#devops [3]: https://microsoft.github.io/PSRule/latest/features/#extensible [4]: https://microsoft.github.io/PSRule/latest/features/#reusable
Project objectives
1. Extensible:
- Provide an execution environment (tools and language) to validate infrastructure code.
- Handling of common concerns such as input/ output/ reporting should be handled by the engine.
- Language must be flexible enough to support a wide range of use cases.
2. DevOps:
- Validation should support and enhance DevOps workflows by providing fast feedback in pull requests.
- Allow quality gates to be implemented between environments such development, test, and production.
3. Cross-platform:
- A wide range of platforms can be used to author and deploy infrastructure code.
PSRule must support rule validation and authoring on Linux, MacOS, and Windows.
- Runs in a Linux container.
For continuous integration (CI) systems that do not support PowerShell, run in a container. 4. Reusable:
- Validation should plug and play, reusable across teams and organizations.
- Any reusable validation will have exceptions.
Rules must be able to be disabled where they are not applicable.
Continue reading the [PSRule design specification][5].
[5]: docs/specs/design-spec.md
> Back to the [summary](#summary)
Support
This project uses GitHub Issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates.
- For new issues, file your bug or feature request as a new [issue][6].
- For help, discussion, and support questions about using this project, join or start a [discussion][7].
Support for this project/ product is limited to the resources listed above.
[6]: https://github.com/Microsoft/PSRule/issues [7]: https://github.com/microsoft/PSRule/discussions
> Back to the [summary](#summary)
Getting the module
You can download and install the PSRule module from the PowerShell Gallery.
Module | Description | Downloads / instructions ------ | ----------- | ------------------------ PSRule | Validate infrastructure as code (IaC) and objects using PowerShell rules. | [latest][8] / [instructions][9]
For rule and integration modules see [related projects][10].
[8]: https://www.powershellgallery.com/packages/PSRule [9]: https://microsoft.github.io/PSRule/v2/install-instructions/ [10]: https://microsoft.github.io/PSRule/v2/related-projects/
> Back to the [summary](#summary)
Getting extensions
Companion extensions are available for the following platforms.
Platform | Description | Downloads / instructions -------- | ----------- | ------------------------ Azure Pipelines | Validate infrastructure as code (IaC) and DevOps repositories using Azure Pipelines. | [latest][11] / [instructions][9] GitHub Actions | Validate infrastructure as code (IaC) and DevOps repositories using GitHub Actions. | [latest][12] / [instructions][9] Visual Studio Code | Visual Studio Code extension for PSRule. | [latest][13] / [instructions][9]
[11]: https://marketplace.visualstudio.com/items?itemName=bewhite.ps-rule [12]: https://github.com/marketplace/actions/psrule [13]: https://marketplace.visualstudio.com/items?itemName=bewhite.psrule-vscode
> Back to the [summary](#summary)
Getting started
For an quickstart example of using PSRule see Create a standalone rule. For specific use cases see [scenarios](#scenarios).
For frequently asked questions, see the FAQ.
> Back to the [summary](#summary)
Scenarios
For walk through examples of PSRule usage see:
- Validate Azure resource configuration
- Validate Azure resources tags
- Validate Kubernetes resources
- Using within continuous integration
- Packaging rules in a module
- Writing rule help
> Back to the [summary](#summary)
Language reference
PSRule extends PowerShell with domain specific language (DSL) keywords, cmdlets and automatic variables.
Keywords
The following language keywords are used by the PSRule module:
- Rule - A rule definition.
- Exists - Assert that a field or property must exist.
- Match - Assert that the field must match any of the regular expressions.
-...
Excerpt shown — open the source for the full document.
Notability
notability 5.0/10New Microsoft repo with moderate stars.