Getting Fromat of Hashtable a cmdlet supports

This topic contains 3 replies, has 2 voices, and was last updated by  Robert Westerlund 3 years, 8 months ago.

  • Author
    Posts
  • #14033

    ved369
    Participant

    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!!!

  • #14040

    Robert Westerlund
    Participant

    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:

    -Property 
        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 
  • #14042

    ved369
    Participant

    Thank you Robert ...

    It seems i need to give attention to property help.

  • #14043

    Robert Westerlund
    Participant

    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.

You must be logged in to reply to this topic.