Exploring PowerShell "Suggestions"

by Aug 7, 2013

In the PowerShell console, you may have noticed "suggestions" that appear with common errors. Suggestions are designed to help you better understand the error.

Suggestions are hard-coded into PowerShell and only appear in the console. They do not appear in the ISE editor.

To get a list of all suggestions implemented, try this:

$PSType = [PSObject].Assembly.GetType('System.Management.Automation.HostUtilities', $true)
$PSType.GetField('suggestions', 'Static,NonPublic,GetField').GetValue($null) | 
  ForEach-Object { New-Object -TypeName PSObject -Property $_ } |

As it turns out, there are only three suggestions implemented. To see a suggestion in action, enter this in a PowerShell console window:

PS> cd 'C:\Program Files\Internet Explorer'

PS> iexplore

iexplore : The term 'iexplore' is not recognized as the name of a cmdlet, function,script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


Suggestion [3,General]: The command iexplore was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type ".\iexplore". See "get-help about_Command_Precedence" for more details.

Twitter This Tip! ReTweet this Tip!