September 3rd, 2014

PowerTip: Use PowerShell to Copy Array

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to copy an array. Hey, Scripting Guy! Question How can I use Windows PowerShell to copy the contents of one array over another array?

Hey, Scripting Guy! Answer One way to do this is to use the Copy static method from the System.Array .NET Framework class, for example:

PS C:> $a = 1,2,3,4,5

PS C:> $b = 6,7,8,9,10

PS C:> [array]::copy($a,$b,5)

PS C:> $b

1

2

3

4

5

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback