Question

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.

Was it helpful?

Solution

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).

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top