Add Col to result format-table

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 6 years, 5 months ago.

  • Author
  • #5693

    by staggerlee011 at 2013-03-20 01:48:30

    hi all,

    So im gather a bunch of a data and formatting it in a table. Id like to add a column which has the date but i cant work out how to put the date in the each row, when i try it addds a column header with the date instead (Makes sense why, but not sure how to get around it!)

    hope someone can help..

    Example of what im trying:

    $date = get-date -format yyyyMMdd

    $db | select-object $date, parent, name, size, spaceavailable | ft

    by Klaas at 2013-03-20 02:07:36

    I think it should work like this:
    $db | select-object @{l='date';e={$date}}, parent, name, size, spaceavailable | ft

    by staggerlee011 at 2013-03-20 02:12:30

    perfect! thank you...

    I was just reading about expressions and though i was on to something....

    i thought it said you had to use it for everythign to work though.. so i had

    $date = get-date -format yyyyMMdd

    $db | select-object
    @{Name="Available";Expression={$_."spaceavailable"}} | ft -AutoSize

    strangely toke it out of table format and back into form..

    thanks 🙂

You must be logged in to reply to this topic.