0

I have two arrays with different values as follows

$DevID={101,102,103,104}
$ProdID={201,202,203,204}

And I want the output to be printed as the first DevID followed by ProdID,as shown below,

101
201

102
202

103
203

104
204

How can I get the above shown output in PowerShell?

1
  • Please make some effort to implement it in PowerShell, and then state the specific problem you have with your implementation, we're here to help you, not to solve the problem for you. Commented Jul 20, 2016 at 7:58

1 Answer 1

1

Using the curly bracket you defined two scriptblocks. You instead want to use @(....):

$DevID=@(101,102,103,104)
$ProdID=@(201,202,203,204)

Now to get your desired output you could use a for-loop and access the lists by the current index:

for ($i = 0; $i -lt $DevID.Count; $i++)
{
    $DevID[$i]
    $ProdID[$i]
}

Output:

101
201
102
202
103
203
104
204
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.