Tabelle erstellen: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) K |
Admin (Diskussion | Beiträge) K |
||
Zeile 28: | Zeile 28: | ||
#NOTE: Now you can also export this table to a CSV file as shown below. | #NOTE: Now you can also export this table to a CSV file as shown below. | ||
− | $tabCsv = $table | export-csv $ | + | $tabCsv = $table | export-csv $getPathoutput.csv -noType |
</source> | </source> | ||
Zeile 39: | Zeile 39: | ||
$ObjectTable = @($obj1,$obj2) | $ObjectTable = @($obj1,$obj2) | ||
</source> | </source> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Quellen: | ||
+ | ''*https://stackoverflow.com/questions/26479517/how-can-i-create-a-table-in-powershell-using-variables-and-data-i-input'' | ||
+ | |||
[[Kategorie:PowerShell]] | [[Kategorie:PowerShell]] |
Version vom 11. August 2017, 09:05 Uhr
Offizielle PowerShell Tabelle erstellen
$TableName = "SampleTable" #Create Table object $table = New-Object system.Data.DataTable “$TableName” #Define Columns $col1 = New-Object system.Data.DataColumn ColumnName1,([string]) $col2 = New-Object system.Data.DataColumn ColumnName2,([string]) #Add the Columns $table.columns.add($col1) $table.columns.add($col2) #Create a row $row = $table.NewRow() #Enter data in the row $row.ColumnName1 = "A" $row.ColumnName2 = "1" #Add the row to the table $table.Rows.Add($row) #Display the table $table | format-table -AutoSize #NOTE: Now you can also export this table to a CSV file as shown below. $tabCsv = $table | export-csv $getPathoutput.csv -noType
Tabelle mittels PowerShell-Objekte erstellen
$obj1 = New-Object PSObject -Property @{"Spalte 1"="Wert 1"; "Spalte 2"="Wert 1"} $obj2 = New-Object PSObject -Property @{"Spalte 1"="Wert 2"; "Spalte 2"="Wert 2"} $ObjectTable = @($obj1,$obj2)