Author Posts

January 1, 2012 at 12:00 am

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="Date";Expression={$date}},
@{Name="Server";Expression={$_."Parent"}},
@{Name="Database";Expression={$_."name"}},
@{Name="Size";Expression={$_."size"}},
@{Name="Available";Expression={$_."spaceavailable"}} | ft -AutoSize

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

thanks 🙂