Frage

I want to hide a PowerShell Cmdlet parameter from user. Is there any way to do this in C#?

I want to use this parameter within my code to trigger the same cmdlet with the hidden parameter.

I use PowerShell 2.0.

Thanks.

War es hilfreich?

Lösung

In PowerShell 4.0 you can hide a parameter using the ParameterAttribute.DontShow property. That said, the parameter is hidden only from tab completion (PowerShell Magazine tip).

Andere Tipps

If you can't find a way to hide the parameter (e.g. from Get-Help) you can "hide" it in plain sight by using a common parameter that it's unlikely a user would ever specify, like -OutBuffer 0, and test for the presence of that in PSBoundParameters.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top