Hi Ana,
You could use $PSBoundParameters
to get the parameters passed to the function and use &
to run a command. The script could be like this
foreach ($Parameter in $PSBoundParameters.Keys) {
if ($parameter -ne "MyObject") {
$cmd = "Set-" + $Parameter
&$cmd -Object $MyObject
}
}
When you run ABCDE -OptionA -OptionB -MyObject $obj
, the function will call Set-OptionA -Object $obj
and Set-OptionB -Object $obj
Best Regards,
Ian
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.