title: How can I increase the value of a variable in an expression?
body: <p>I have the following code:</p>
  
  <pre><code>$b = 1
  Import-Csv c:\Awsaf\powershell\Beforenew.csv | select name, CustomAttribute1, CustomAttribute2, @{n='Counter';e={$b}} | Export-Csv -NoTypeInformation c:\Awsaf\PowerShell\afternew.csv
  </code></pre>
  
  <p>I want to increment the value of $b by 1. I have tried $b++, $b+=, for loop, do-while, nothing seems to be working. How can I do it?</p>
  
  <p>I have also tried the following additional code, but I cannot figure out how to increase the value of $b.</p>
  
  <pre><code>$b = 0
  Import-CSV c:\Awsaf\powershell\afternew.csv -Delimiter ',' | `
  ForEach-Object { $_.Counter = "$b"; return $_ } | `
  Export-CSV c:\awsaf\powershell\afterX.csv -Delimiter ',' -NoTypeInformation
  </code></pre>