title: How do I remove a trailing comma from a string
body: <p>I have a string producing results in PowerShell being separated by a comma, which is fine, but I don't want the last comma. </p>
  
  <p>I understand a Trim function is required, but I can't seem to get it to work. Maybe i've been trying it in the wrong place? </p>
  
  <p>I need it to return three "Site Codes, each separated with a comma, and no comma at the end. I need to know where to add the trim bit really. </p>
  
  <pre><code>$UKPRN = "10007405"
  $str_sites = "A4EYORK,AVLEEDS,BANBURY";
  
  $sites = "";
  
  
  foreach ($site in $str_sites.Split(","))
  {
  $sites = $sites+"'"+$site+"',"
  
  }
  Write-Output $sites;
  </code></pre>