PSRule icon indicating copy to clipboard operation
PSRule copied to clipboard

Transform objects processed by rules

Open BernieWhite opened this issue 6 years ago • 0 comments

Currently PSRule validates objects passed to it against a set of rules. Matching rules produce result data for reporting based on pass or failure.

PSRule can be further extended to transform/ mutate objects that don't pass rule conditions with the intent of making the object compliant.

i.e. An object doesn't have a property that should be set, when the value the property should be set to is known, then set the property.

For example:

# Description: Use HTTPS only
Rule 'appServiceApp.UseHTTPS' -If { ResourceType 'Microsoft.Web/sites' } {
    Hint 'Disable HTTP when not required'

    $TargetObject.Properties.httpsOnly -eq $True

    Recommend -Update {
        $TargetObject.Properties.httpsOnly = $True
    }
}
Update-PSRuleTarget

BernieWhite avatar Mar 30 '19 02:03 BernieWhite