Tabelle erstellen
Aus Wiki-WebPerfect
Version vom 11. August 2017, 09:05 Uhr von Admin (Diskussion | Beiträge)
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)