You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PSRule already includes a number of built-in keywords that can be used to build out rules quickly.
In complex scenarios the behavior may not be desirable.
Consider:
# Synopsis: VNETs should have at least two DNS servers assigned
Rule 'Azure.VirtualNetwork.SingleDNS' {
# If DNS servers are customized, at least two IP addresses should be definedif (!(Exists 'properties.dhcpOptions.dnsServers') -or ($TargetObject.properties.dhcpOptions.dnsServers.Count-eq0)) {
$True;
}
else {
$TargetObject.properties.dhcpOptions.dnsServers.Count-ge2;
}
}
In this example Exists is useful for checking if a nested field exists. However logging within verbose logs may confuse the intent of the rule.
Secondarily, while builtin keywords make it easy to build out rules quickly, the vocabulary is must be limited to reduce keyword clash with other DSL PowerShell modules.
The text was updated successfully, but these errors were encountered:
PSRule already includes a number of built-in keywords that can be used to build out rules quickly.
In complex scenarios the behavior may not be desirable.
Consider:
In this example
Exists
is useful for checking if a nested field exists. However logging within verbose logs may confuse the intent of the rule.Secondarily, while builtin keywords make it easy to build out rules quickly, the vocabulary is must be limited to reduce keyword clash with other DSL PowerShell modules.
The text was updated successfully, but these errors were encountered: