Why is my PowerShell multi dimensional array being interpreted as a 1 dimensional array?
Posted
by Jim
on Stack Overflow
See other posts from Stack Overflow
or by Jim
Published on 2010-05-21T17:37:00Z
Indexed on
2010/05/21
17:40 UTC
Read the original article
Hit count: 254
I have the following code:
function HideTemplates($File, $Templates)
{
foreach ($Template in $Templates)
{
Write-Host $Template[0] $Template[1] $Template[2]
}
}
HideTemplates "test.xml" @(("one", "two", "three"))
HideTemplates "test.xml" @(("four", "five", "six"), ("seven", "eight", "nine"))
It prints:
o n e
t w o
t h r
four five six
seven eight nine
I want it to print:
one two three
four five six
seven eight nine
Am I doing something wrong in my code? Is there a way to force PowerShell to tread a multi-dimensional array with a single item differently?
© Stack Overflow or respective owner