Hiding Parameters from IntelliSense

by Oct 28, 2013

Beginning with PowerShell 4.0, a script author can decide to hide function parameters from IntelliSense. This way, less frequently used parameters can be omitted from ISE IntelliSense menus:

function Test-Function
{
    param(
        $Name,
        [Parameter(DontShow)]
        [Switch]
        $IAmSecret
    )
    
    if ($IAmSecret)
    {
     "Doing secret things with $Name"
    }
    else
    {
      "Regular behavior with $Name"
    }
} 

When you run this function in PowerShell 4.0 ISE, only "Name" will appear in the parameter IntelliSense list. However, once you indicate that you know the hidden parameter, and start entering at least the first letter, then pressing (TAB) will show the parameter:

Hidden parameters will always be visible in the help window, which you could open like this:

Twitter This Tip! ReTweet this Tip!