Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which parameter set has been used?

I've used advanced parameter handling to support multiple parameter sets. Is there any pre-defined variable or way to determine which parameter set has been used to call the script?

e.g. something like

if($parameterSet -eq "set1") { ... } elseif ($parameterSet -eq "set2") { ... } 

?

like image 510
D.R. Avatar asked Apr 02 '13 11:04

D.R.


People also ask

What are parameter sets?

Parameter sets enable you to expose different parameters to the user. And, to return different information based on the parameters specified by the user. You can only use one parameter set at a time.

How many parameter sets are defined for the command get service?

As illustrated here, the Get-Process cmdlet has three different parameter sets.

What is CmdletBinding in PowerShell?

The CmdletBinding attribute is an attribute of functions that makes them operate like compiled cmdlets written in C#. It provides access to the features of cmdlets. PowerShell binds the parameters of functions that have the CmdletBinding attribute in the same way that it binds the parameters of compiled cmdlets.

What is PowerShell parameter?

The PowerShell parameter is a fundamental component of any script. A parameter is a way that developers enable script users to provide input at runtime. If a PowerShell script's behavior needs to change in some way, a parameter provides an opportunity to do so without changing the underlying code.


1 Answers

Check the $PSCmdlet variable:

$PSCmdlet.ParameterSetName 
like image 171
Shay Levy Avatar answered Oct 22 '22 08:10

Shay Levy