title: How to merge strings together in a loop in powershell
body: <p>My aim is to send an automated message which contains all the strings from my loop.</p>
  <p>I got a <code>$body</code> variable which is something like</p>
  <blockquote>
  <p>This message shows you how much <code>$size</code> of your <code>$project</code> is used</p>
  </blockquote>
  <p>I want to merge these strings into one variable which I can send through mail, but either it sends in separated mails or only the last loop remains.</p>
  <h1>Code:</h1>
  <pre><code>Enter-PSSession *computer*
  
  $attributes = (Get-FsrmQuota | select Description, Size, PeakUsage)
  
  foreach ($attribute in $attributes)
  {
      $counter = $attributes.Count
      $descr = $attribute.Description
      $size = $attribute.size
      $tomb = @($descr.Split(&quot;;&quot;))
      $mail = $tomb[&quot;1&quot;]   # user mail adress
      $project = $tomb[&quot;0&quot;] # user project
      $name = $mail.Split(&quot;@&quot;)[0] #username
      $firstName = $name.Split(&quot;.&quot;)[0]  
      $lastName = $name.Split(&quot;.&quot;)[1]
      $size = [Math]::Round(($attribute.Size)/1Gb,1).ToString() + &quot; Gb&quot; #storage size
      $usage = [Math]::Round(($attribute.Usage)/1Gb,1).ToString() + &quot; Gb&quot; #storage usage
      $percent = [Math]::Round((($attribute.Usage / $attribute.Size)*100),2).ToString() + &quot;%&quot;
      $projname = $array[&quot;2&quot;] #project name
  
      
      for($i=1; $i -le $counter; $i++)
      {
          $ITBody = &quot;The $projname project uses $size.&quot;
          $array+=$ITBody 
      }
  }
  
  write-host $array
  </code></pre>
  <p>Got the results duplicated soo many times</p>