Providing "Static" IntelliSense for Your Functions

by Nov 12, 2012

To get rich IntelliSense in PowerShell ISE 3.0, you should start adding the OutputType attribute to your functions. If you do, then ISE is able to provide IntelliSense inside your code without the need to actually have real values in your variables.

Here is a simple sample:

function Test-IntelliSense
{
  [OutputType('System.DateTime')]
  param()

  return Get-Date
}

Once you entered this function into ISE 3.0 (do NOT run the code!), try adding these lines:

$a = Test-IntelliSense
$a.

The moment you type a dot after the variable, ISE provides IntelliSense for the System.DateTime data type. Isn't that nice? No need to run the script all the time to fill variables for real-time IntelliSense.

Twitter This Tip! ReTweet this Tip!