PSRule icon indicating copy to clipboard operation
PSRule copied to clipboard

Trigger recommended action processed by rules

Open BernieWhite opened this issue 5 years ago • 4 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 trigger an recommended action when objects don't pass the conditions with the intent of making the object compliant.

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 -Action {
        # Corrective action
    }
}
Invoke-PSRuleAction

BernieWhite avatar Mar 30 '19 02:03 BernieWhite

Any consideration of using capabilities provided with https://github.com/microsoft/Requirements?

gengle avatar Dec 17 '19 13:12 gengle

@gengle Not at the time. At the time i wasn't aware of the project. Thanks.

How would you see that working?

BernieWhite avatar Dec 17 '19 20:12 BernieWhite

@gengle Thanks for the suggestion, I'll have a look at this.

However any thoughts on how you would like it to work would be great.

BernieWhite avatar Dec 17 '19 21:12 BernieWhite

#322 could be used to set a block downstream to Requirements.

BernieWhite avatar Dec 18 '19 13:12 BernieWhite