title: Powershell: Add objects to an array of objects
body: <p>I have this script where I want to add an object to an array called <code>$Target</code> in every foreach.</p>
  
  <pre class="lang-cs prettyprint-override"><code>foreach ($Machine in $Machines)
  {
    $TargetProperties = @{Name=$Machine}  
    $TargetObject = New-Object PSObject –Property $TargetProperties
    $Target= @()
    $Target =  $TargetObject
  }
  </code></pre>
  
  <p>I know it is not working because <code>$Target =  $TargetObject</code> makes it equal to the same object.</p>
  
  <p>How can I append to the array instead of replace?</p>