Powershell-如何使用变量定义要在选择对象中输出的列
我正试图将表的输出减少到以下列Powershell-如何使用变量定义要在选择对象中输出的列,powershell,select,tabular,Powershell,Select,Tabular,我正试图将表的输出减少到以下列 $tcolumns = "JobName,VMname,Sunday 08-06-2014,Saturday 07-06-2014" $Report = $table | select $tcolumns | ConvertTo-HTML -head $style 输出具有一个空列的表 如果我 输出很好 您知道如何使用变量定义要返回的表列吗 $table | get成员的输出 TypeName: System.Data.DataRow Name
$tcolumns = "JobName,VMname,Sunday 08-06-2014,Saturday 07-06-2014"
$Report = $table | select $tcolumns | ConvertTo-HTML -head $style
输出具有一个空列的表
如果我
输出很好
您知道如何使用变量定义要返回的表列吗
$table | get成员的输出
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;}
$table | get成员的输出
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;}
这里需要一个字符串数组,而不是一个碰巧有逗号的字符串。:-) 如本文所述()使用ExcludeProperty
$DataSet.Tables[0] | select * -ExcludeProperty RowError, RowState,
HasErrors, Name, Table, ItemArray | ConvertTo-Html
谢谢Keith,这让我更接近了,但我得到了以下错误选择:无法将System.Object[]转换为以下类型之一{System.String,System.Management.Automation.ScriptBlock}。在C:_admin\Scripts\Get weeklystatus.ps1:314 char:20+$Report=$table | select$tcolumns | ConvertTo HTML-head$style+~~~~~~~~~~~~~~~~~~~~~~~+CategoryInfo:InvalidArgument:(:)[select Object],NotSupportedException+FullyQualifiedErrorId:DictionaryKeyUnknownType,Microsoft.PowerShell.Commands.SelectObjectCommands我需要了解有关
$table
中内容的更多信息。你能把$table | get member的输出添加到你的问题中吗?我已经把$table | get member的输出添加到了问题中。所以有一个星期一2014年6月9日
,而不是星期六2014年6月7日
。此属性名称是否为dymanic,即每行更改为不同的内容?抱歉,是的,它是动态的,在本例中是最后两天。在每一行上都是一样的。
$DataSet.Tables[0] | select * -ExcludeProperty RowError, RowState,
HasErrors, Name, Table, ItemArray | ConvertTo-Html