Difference between revisions of "Power Shell"
Jump to navigation
Jump to search
(→Commands: Added Scalar Query function) |
(→Arrays: Added array table example) |
||
Line 205: | Line 205: | ||
$array = @() # Create blank array | $array = @() # Create blank array | ||
$array += 34 # Add value to end of array | $array += 34 # Add value to end of array | ||
</source> | |||
To create an array (table) with column headings, initialise an array, then create a ''row'' variable with the column headings and add this ''row'' to the array. This is convenient when building a table of data within a loop eg | |||
<source lang="powershell"> | |||
$table = @() | |||
foreach ($instance in $set) { | |||
$row = "" | Select Heading1, Heading2, Heading3 | |||
$row.Heading1 = "something" | |||
$row.Heading2 = "like" | |||
$row.Heading3 = "this" | |||
$table += $row | |||
} | |||
</source> | </source> | ||