Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to have an incrementing Array Object Name

$
0
0

Hi!

I want to add an object to an array withing  a loop. Can anyone tell me how to increment the name of the object?

i.e n the following code I the first time it runs I want it to create an object called $Array_object1, the next time $Array_Object2 etc.

$Array = @()

$count = 1

Foreach($i)
{
     $Array_object = New-Object System.Object


     $Array_object | Add-Member -type NoteProperty -Name Instance -Value $i

     $Array += $Array_object
     $count ++
}

Thanks,

Zoe




Viewing all articles
Browse latest Browse all 21975

Trending Articles