title: Powershell Foreach-Object Foreach loop read string from several files and write to one
body: <p>I have trouble to use several commands in one Foreach or Foreach-Object loop</p>
  
  <p>My situation is -</p>
  
  <ol>
  <li>I have many text files, about 100. 
  So they are read <code>Get-ChildItem $FilePath -Include *.txt</code></li>
  <li><p>Every file's structure is same only key information is different.
  Example</p>
  
  <p>User: Somerandomname</p>
  
  <p>Computer: Somerandomcomputer</p></li>
  </ol>
  
  <p>With <code>-Replace</code> command I remove "User:" and "Computer:" so <code>$User = Somerandomname</code> and <code>$computer = "Somerandomcomputer</code>.
  In each circle $user and $Computer with -Append should be written to one file. And then next file should be read.</p>
  
  <pre><code>foreach-object { $file = $_.fullname;
  </code></pre>
  
  <p>should be used, but I can not figure out the right syntax for it. Could someone help me with it?</p>