title: Powershell: Reading in a column from a .CSV file and then adding a specific string to the beginning and exporting again
body: <p>I'm attempting to write a script which will read in a CSV generated by querying AD for user information (that part is done) but then will allow me to add a string to the beginning of each value of a column in the CSV file and then export it.</p>
  
  <p>For instance we have this CSV file:</p>
  
  <blockquote>
    <p>"displayname","Office"<br>
    Bob,7142<br>
    Janet,8923<br>
    SantaClaus,0912<br>
    NicCage,0823<br></p>
  </blockquote>
  
  <p>I want to take each entry for "Office", add the string "BUG" before it and then export it back out. The modified CSV should look like:</p>
  
  <blockquote>
    <p>"displayname","Office"<br>
    Bob,BUG7142<br>
    Janet,BUG8923<br>
    SantaClaus,BUG0912<br>
    NicCage,BUG0823<br></p>
  </blockquote>
  
  <p>At this point, I've been attempting to read in just the "Office" column and then displaying it with "Write-Host". The idea being that if I can do that then maybe I can create a new variable that would be something like:</p>
  
  <pre><code>$BUG = "BUG"
  $NewVar = $BUG$Office
  </code></pre>
  
  <p>Which would hopefully look like the second CSV file. I am extremely new to powershell scripting.</p>
  
  <p>The attempts I've made so far are these:</p>
  
  <p>Attempt #1:</p>
  
  <pre><code>$UserList = Import-CSV C:\Users\username\CSV.csv
  $UserList | ForEach-Object ($_.Office) { $UserList }
  </code></pre>
  
  <p>Attempt #2:</p>
  
  <pre><code>$projectName = import-csv  C:\Users\username\CSV.csv | % {$_.Office}
  $BUG = "BUG"
  $projectName | ForEach-Object ($_) {$projectName}
  </code></pre>
  
  <p>Attempt #3:</p>
  
  <pre><code>$UserList = Import-CSV C:\Users\username\CSV.csv
  #ForEach ($Office in $Userlist) {
  #Write-Host $UserList.Office
  #}
  </code></pre>
  
  <p>Attempt #4:</p>
  
  <pre><code>Import-Csv "C:\Users\username\CSV.csv" -Header       ("displayname","Office","whenCreated","EmailAddress") | Select-Object Office | Export-CSV -Path C:\users\Username\test.csv
  </code></pre>
  
  <p>I have gotten it to read out just the Office numbers before using the ForEach-Object loop structure but then it never stops reading out the office numbers so that's unhelpful.</p>
  
  <p>I think I'm going in the right direction, but I just can't figure out how to modify a column like this.</p>