-
Notifications
You must be signed in to change notification settings - Fork 9
Assert BoundParameter
Throws an error if there is a bound parameter that exists in both the mutually exclusive lists.
Assert-BoundParameter -BoundParameterList <Hashtable> -MutuallyExclusiveList1 <String[]>
-MutuallyExclusiveList2 <String[]> [<CommonParameters>]
Assert-BoundParameter -BoundParameterList <Hashtable> -RequiredParameter <String[]>
[-IfParameterPresent <String[]>] [<CommonParameters>]
This command asserts passed parameters.
It takes a hashtable, normally
$PSBoundParameters
.
There are two parameter sets for this command.
There is no built in logic to validate against parameters sets for DSC so this can be used instead to validate the parameters that were set in the configuration.
MutuallyExclusiveParameters
This parameter set takes two mutually exclusive lists of parameters. If any of the parameters in the first list are specified, none of the parameters in the second list can be specified.
RequiredParameter
Assert that required parameters has been specified, and throws an exception if not. Optionally it can be specified that parameters are only required if a specific parameter has been passed.
$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @(
'Parameter1'
)
MutuallyExclusiveList2 = @(
'Parameter2'
)
}
Assert-BoundParameter @assertBoundParameterParameters
This example throws an exception if $PSBoundParameters
contains both
the parameters Parameter1
and Parameter2
.
Assert-BoundParameter -BoundParameterList $PSBoundParameters -RequiredParameter @('PBStartPortRange', 'PBEndPortRange')
Throws an exception if either of the two parameters are not specified.
Assert-BoundParameter -BoundParameterList $PSBoundParameters -RequiredParameter @('Property2', 'Property3') -IfParameterPresent @('Property1')
Throws an exception if the parameter 'Property1' is specified and either of the required parameters are not.
The parameters that should be evaluated against the mutually exclusive lists MutuallyExclusiveList1 and MutuallyExclusiveList2. This parameter is normally set to the $PSBoundParameters variable.
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
One or more parameter names that if specified will trigger the evaluation. If neither of the parameter names has been specified the evaluation of required parameters are not made.
Type: String[]
Parameter Sets: RequiredParameter
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
An array of parameter names that are not allowed to be bound at the same time as those in MutuallyExclusiveList2.
Type: String[]
Parameter Sets: MutuallyExclusiveParameters
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
An array of parameter names that are not allowed to be bound at the same time as those in MutuallyExclusiveList1.
Type: String[]
Parameter Sets: MutuallyExclusiveParameters
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
One or more parameter names that is required to have been specified.
Type: String[]
Parameter Sets: RequiredParameter
Aliases:
Required: True
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.
- Assert-BoundParameter
- Assert-ElevatedUser
- Assert-IPAddress
- Assert-Module
- Compare-DscParameterState
- Compare-ResourcePropertyState
- ConvertFrom-DscResourceInstance
- ConvertTo-CimInstance
- ConvertTo-HashTable
- Find-Certificate
- Get-ComputerName
- Get-DscProperty
- Get-EnvironmentVariable
- Get-LocalizedData
- Get-LocalizedDataForInvariantCulture
- Get-PSModulePath
- Get-TemporaryFolder
- Get-UserName
- New-ArgumentException
- New-ErrorRecord
- New-Exception
- New-InvalidDataException
- New-InvalidOperationException
- New-InvalidResultException
- New-NotImplementedException
- New-ObjectNotFoundException
- Remove-CommonParameter
- Set-DscMachineRebootRequired
- Set-PSModulePath
- Test-AccountRequirePassword
- Test-DscParameterState
- Test-DscProperty
- Test-IsNanoServer
- Test-IsNumericType
- Test-ModuleExist