PSRule
PSRule copied to clipboard
Transform objects processed by rules
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