Skip to content

Validating locally#

PSRule can be installed locally on MacOS, Linux, and Windows for local validation. This allows you to test Infrastructure as Code (IaC) artifacts before pushing changes to a repository.

Tip

If you haven't already, follow the instructions on installing locally before continuing.

With Visual Studio Code#

Extension

An extension for Visual Studio Code is available for an integrated experience using PSRule. The Visual Studio Code extension includes a built-in task PSRule: Run analysis task.

Built-in tasks shown in task list

Info

To learn about tasks in Visual Studio Code see Integrate with External Tools via Tasks.

Customizing the task#

The PSRule: Run analysis task will be available automatically after you install the PSRule extension. You can customize the defaults of the task by editing or inserting the task into .vscode/tasks.json within your workspace.

JSON
{
    "type": "PSRule",
    "problemMatcher": [
        "$PSRule"
    ],
    "label": "PSRule: Run analysis",
    "modules": [
        "PSRule.Rules.Azure"
    ],
    "presentation": {
        "clear": true,
        "panel": "dedicated"
    }
}

Example

A complete .vscode/tasks.json might look like the following:

.vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "PSRule",
            "problemMatcher": [
                "$PSRule"
            ],
            "label": "PSRule: Run analysis",
            "modules": [
                "PSRule.Rules.Azure"
            ],
            "presentation": {
                "clear": true,
                "panel": "dedicated"
            }
        }
    ]
}

Last update: 2022-08-26

Comments