title: Concatenating PowerShell variables
body: <pre class="lang-powershell prettyprint-override"><code>$timeout = new-timespan -Minutes 1
  $sw = [diagnostics.stopwatch]::StartNew()
  $path = "d:\powershell\test.csv"
  
  "Processor Load, Available Memory(MB), Max Memory(Bytes)" &gt;&gt; $path
  
  while ($sw.elapsed -lt $timeout)
  {
      $a = gwmi -query "Select * from win32_processor"
      $b = gwmi -query "Select * from win32_perfrawdata_perfOS_memory"
      $c = gwmi -query "Select * from win32_physicalmemory"
      $date = Get-Date -format s
  
      $a.loadpercentage + "," + $b.availableMbytes + "," + $c.capacity &gt;&gt; $path
      start-sleep -seconds 5
  }
  </code></pre>
  
  <p>So I'm just looking to get a minute long snapshot of what's going on. I'm not just opening this in perfmon for reasons. Basically I'd expect to get a comma-delimited output in the CSV file mentioned. It works for a single variable, but when I try to add a second variable, or text I get the following error.</p>
  
  <pre class="lang-powershell prettyprint-override"><code>Cannot convert value ", test" to type "System.Int32". Error: "Input string was not in a
  correct format."
  At D:\powershell\VDIPerfMon.ps1:14 char:21
  +     $a.loadpercentage + &lt;&lt;&lt;&lt;  ", test" &gt;&gt; $path
  + CategoryInfo          : NotSpecified: (:) [], RuntimeException
  + FullyQualifiedErrorId : RuntimeException
  </code></pre>
  
  <p>How can I fix this problem?</p>