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.
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.