PowerTip: Use PowerShell to Copy Array

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