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.

有帮助吗?

解决方案

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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top