title: Updating PSObject hash table in loop
body: <p>Here is a part code of uploading data by FTP </p>
  
  <pre><code>foreach ($line in $FTPServer)
      {
          Start-Transcript -Path $results            
          Write-Host -Object "ftp url: $line"
          If (Test-Connection $line -Count 1)
          {
  
              Set-FTPConnection -Credentials $FTPCredential -Server $line -Session MySession -UsePassive -ErrorAction SilentlyContinue
              $Session = Get-FTPConnection -Session MySession
              if($session.UsePassive -eq "True"){$connect="OK"}
              else{$connect="!!!-FAIL-!!!"}
  
              foreach ($item in (Get-ChildItem .\Upload))
                  {
                      Write-Host -Object "Uploading $item..."
                      $Send= Add-FTPItem -Session $Session -Path $FTPPlace -LocalPath .\Upload\$item -Overwrite -ErrorAction SilentlyContinue
                      if($Send.Name -eq $item.Name){$Rec="OK"}
                      else{$Rec="!!!-FAIL-!!!"}
                      $array = $line, $item, $connect, $Rec
                      $FailTable=New-Object -TypeName PSObject -Property ([ordered]@{"FTP Server"=$array[0]; "File"=$array[1];"Connected"=$array[2];"Uploaded"=$array[3]})
  
                      $FailTable|Out-File -Append '.\stats.txt'
                  }
          Stop-Transcript
          } Else {"$line"&gt;&gt; .\DownServers.txt}
      }
  </code></pre>
  
  <p><code>$Failtable</code> is a hash-table that stores ip of FTP server (<code>$line</code>), name of uploaded file (<code>$item</code>), status if connected (<code>$connect</code>) and upload status (<code>$Rec</code>). The hash-table is piped to file <code>.\stats.txt</code> The problem is in every iteration to .\stats.txt are saved headers like that: </p>
  
  <pre><code>FTP Server  File                    Connected Uploaded    
  ----------  ----                    --------- --------    
  192.168.1.1 ConfigurationDivide.xml OK        !!!-FAIL-!!!
  
  
  
  FTP Server  File     Connected Uploaded    
  ----------  ----     --------- --------    
  192.168.1.1 test.txt OK        !!!-FAIL-!!!
  </code></pre>
  
  <p>So I need that to be one under another and autosized like that:</p>
  
  <pre><code>FTP Server  File                    Connected Uploaded    
  ----------  ----                    --------- --------    
  192.168.1.1 ConfigurationDivide.xml OK        !!!-FAIL-!!!    
  192.168.1.1 test.txt                OK        !!!-FAIL-!!!
  </code></pre>
  
  <p>I tryed to put hash-table declaration  <code>$FailTable=New-Object -TypeName PSObject -Property ([ordered]@{"FTP Server"=$array[0]; "File"=$array[1];"Connected"=$array[2];"Uploaded"=$array[3]})</code> before loops and then- in the loops add values (<code>$line</code>, <code>$item</code>,...), but there aren't in hashtable <code>.add</code> method.</p>