I have this script where I want to add an object to an array called $Target in every foreach.
$Target
foreach ($Machi
To append to an array, just use the += operator.
+=
$Target += $TargetObject
Also, you need to declare $Target = @() before your loop because otherwise, it will empty the array every loop.
$Target = @()