I am wondering how one would tackle looping through a collection of objects, processing the elements of that collection in groups instead of singularly, as is the case in no
You guys definitely gave me some great ideas for this functionality. I ended up going with the following:
#create base collection
$group = get-vm
$i = 0
do {
new-variable -Name "subgroup$i" -value $group[0..4]
++$i
$group = $group[5..$group.length]
}
while ($group.length -gt 0)
This code results in a number of subgroups, which is based on how many times the base collection is divisible by 5, which is the desired subgroup quantity in this case......