Good afternoon
Unfortunately, PowerShell is not able to detect the ParameterSet by the Parameter Types, for example: If the 2nd Parameter is passed as a Int, then select ParameterSet1, otherwise use ParameterSet2.
Therefore I would like to manually detect the passed Parameter-Combinations.
Is it possible to get the list of passed parameters in DynamicParam
, something like this?:
Function Log {
[CmdletBinding()]
Param ()
DynamicParam {
# Is is possible to access the passed Parameters?,
# something like that:
If (Args[0].ParameterName -eq 'Message') { … }
# Or like this:
If (Args[0].Value -eq '…') { … }
}
…
}
Thanks a lot for any help and light!
Thomas
This first finding was wrong!: "I've found the magic, by using
$PSBoundParameters
we can access the passed parameters."This is the correct but very disappointing answer:
It's very annoying and unbelievable, but it looks like PowerShell does not pass any information about the dynamically passed arguments.
The following example used the
New-DynamicParameter
function as defined here: Can I make a parameter set depend on the value of another parameter?