external help file | Module Name | online version | schema |
---|---|---|---|
PSRule-help.xml |
PSRule |
2.0.0 |
Create options to configure PSRule execution.
New-PSRuleOption [[-Option] <PSRuleOption>] [-BaselineConfiguration <BaselineConfiguration>]
[-SuppressTargetName <SuppressionOption>] [-BindTargetName <BindTargetName[]>]
[-BindTargetType <BindTargetName[]>] [[-Path] <String>] [<CommonParameters>]
The New-PSRuleOption cmdlet creates an options object that can be passed to PSRule cmdlets to configure execution.
$option = New-PSRuleOption -Option @{ 'execution.mode' = 'ConstrainedLanguage' }
@{ Name = 'Item 1' } | Invoke-PSRule -Option $option
Create an options object and run rules in constrained mode.
$option = New-PSRuleOption -SuppressTargetName @{ 'storageAccounts.UseHttps' = 'TestObject1', 'TestObject3' };
Create an options object that suppresses TestObject1
and TestObject3
for a rule named storageAccounts.UseHttps
.
# Create a custom function that returns a TargetName string
$bindFn = {
param ($TargetObject)
$otherName = $TargetObject.PSObject.Properties['OtherName'];
if ($otherName -eq $Null) {
return $Null
}
return $otherName.Value;
}
# Specify the binding function script block code to execute
$option = New-PSRuleOption -BindTargetName $bindFn;
Creates an options object that uses a custom function to bind the TargetName of an object.
$option = New-PSRuleOption -BaselineConfiguration @{ 'appServiceMinInstanceCount' = 2 };
Create an options object that sets the appServiceMinInstanceCount
baseline configuration option to 2
.
Additional options that configure execution. Option also accepts a hashtable to configure options.
For more information on PSRule options see about_PSRule_Options.
Type: PSRuleOption
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The path to a YAML file containing options.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Configures suppression for a list of objects by TargetName. SuppressTargetName also accepts a hashtable to configure rule suppression.
For more information on PSRule options see about_PSRule_Options.
Type: SuppressionOption
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Configures a custom function to use to bind TargetName of an object.
For more information on PSRule options see about_PSRule_Options.
Type: BindTargetName[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Configures a set of baseline configuration values that can be used in rule definitions instead of using hard coded values. BaselineConfiguration also accepts a hashtable of configuration values as key/ value pairs.
For more information on PSRule options see about_PSRule_Options.
Type: BaselineConfiguration
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Configures a custom function to use to bind TargetType of an object.
For more information on PSRule options see about_PSRule_Options.
Type: BindTargetName[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).