Powershell - How to use a variable to define columns to output in a select-object -
i'm trying cut down output of table following columns
$tcolumns = "jobname,vmname,sunday 08-06-2014,saturday 07-06-2014" $report = $table | select $tcolumns | convertto-html -head $style
outputs table has 1 empty column
if i
$report = $table | select jobname,vmname,"sunday 08-06-2014","saturday 07-06-2014" | convertto-html -head $style
it outputs fine.
any idea on how can use variable define table columns return?
output of $table | get-member
output of $table | get-member
typename: system.data.datarow name membertype definition ---- ---------- ---------- acceptchanges method void acceptchanges() beginedit method void beginedit() canceledit method void canceledit() clearerrors method void clearerrors() delete method void delete() endedit method void endedit() equals method bool equals(system.object obj) getchildrows method system.data.datarow[] getchildrows(string relationname), system.data.datarow... getcolumnerror method string getcolumnerror(int columnindex), string getcolumnerror(string columnn... getcolumnsinerror method system.data.datacolumn[] getcolumnsinerror() gethashcode method int gethashcode() getparentrow method system.data.datarow getparentrow(string relationname), system.data.datarow g... getparentrows method system.data.datarow[] getparentrows(string relationname), system.data.dataro... gettype method type gettype() hasversion method bool hasversion(system.data.datarowversion version) isnull method bool isnull(int columnindex), bool isnull(string columnname), bool isnull(sy... rejectchanges method void rejectchanges() setadded method void setadded() setcolumnerror method void setcolumnerror(int columnindex, string error), void setcolumnerror(stri... setmodified method void setmodified() setparentrow method void setparentrow(system.data.datarow parentrow), void setparentrow(system.d... tostring method string tostring() item parameterizedproperty system.object item(int columnindex) {get;set;}, system.object item(string co... jobname property string jobname {get;set;} monday 09-06-2014 property string monday 09-06-2014 {get;set;} sunday 08-06-2014 property string sunday 08-06-2014 {get;set;} vmname property string vmname {get;set;}
as mentioned here (powershell display table in html email) use excludeproperty
$dataset.tables[0] | select * -excludeproperty rowerror, rowstate, haserrors, name, table, itemarray | convertto-html
Comments
Post a Comment