December 3rd, 2014

PowerTip: Use PowerShell to Hide Parameter From IntelliSense

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to hide a parameter from IntelliSense. Hey, Scripting Guy! Question How can I use Windows PowerShell to hide a parameter from IntelliSense?

Hey, Scripting Guy! Answer Introduced in Windows PowerShell 4.0, you can specify the DontShow attribute
           for the [parameter()] type to hide that parameter from IntelliSense:

Function Test-Something {

    [cmdletbinding()]

    Param (

        [parameter(DontShow)]

        $HiddenParameter,

        [parameter()]

        $Computername,

        [parameter()]

        $NewValue

    )

}

Cycling through parameters will not show $HiddenParameter:

PS C:> Test-Something – #Tab through parameters

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback