Author Posts

March 24, 2014 at 9:20 pm

Hi All,

Recently I came to know that we can even use FormatString as hashtable key to format data as below.

Get-Process | ft Name,ID,@{name='VM'; exp={$_.VM/1MB};formatstring='N2'}

The thing is I never knew this, even I read help for Format-Table, but it is not documented there.

So my question is there a way I can find out what format of hastable a cmdlet supports, can I discover it by some code?

Thanks in Advance!!!

March 24, 2014 at 11:58 pm

You can find documentation about it in the help section on the Format-Table commandlet. If you do:

Get-Help Format-Table -Parameter Property

You will be presented with the following information, which mentions the possible options for the hashtable keys:

    Specifies the object properties that appear in the display and the order in which they appear. Type one or more pro
    perty names (separated by commas), or use a hash table to display a calculated property. Wildcards are permitted.

    If you omit this parameter, the properties that appear in the display depend on the object being displayed. The par
    ameter name ("Property") is optional. You cannot use the Property and View parameters in the same command.

    The value of the Property parameter can be a new calculated property. To create a calculated, property, use a hash
    table. Valid keys are:

    -- Name (or Label) 

    -- Expression  or 

March 25, 2014 at 12:22 am

Thank you Robert ...

It seems i need to give attention to property help.

March 25, 2014 at 12:44 am

You could also do

Get-Help Format-Table -Full

to get all the help sections about a cmdlet. That's how I found it now.