我正在尝试将表格的输出减少到以下列
$tcolumns = "JobName,VMname,Sunday 08-06-2014,Saturday 07-06-2014"
$Report = $table | select $tcolumns | ConvertTo-HTML -head $style
输出一个包含空列
的表如果我
$report = $table | select JobName,VMname,"Sunday 08-06-2014","Saturday 07-06-2014" | ConvertTo-HTML -head $style
输出正常。
关于如何使用变量来定义我想要返回的表列的任何想法?
$ table |的OUTPUT得到构件
$ table |的输出得到构件
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;}
答案 0 :(得分:1)
如此处所述(PowerShell Display Table In HTML Email)使用ExcludeProperty
$DataSet.Tables[0] | select * -ExcludeProperty RowError, RowState,
HasErrors, Name, Table, ItemArray | ConvertTo-Html
答案 1 :(得分:0)
你想要一个字符串数组,而不是一个恰好有逗号的字符串。 : - )
$tcolumns = "JobName","VMname","Sunday 08-06-2014","Saturday 07-06-2014"