I have the following 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
I want to increase the value of $ b by 1. I tried $ b ++, $ b + =, for the loop, do-while, nothing works. How can i do this?
I also tried the following additional code, but I can not figure out how to increase the value of $ b.
$b = 0 Import-CSV c:\Awsaf\powershell\afternew.csv -Delimiter ',' | ` ForEach-Object { $_.Counter = "$b"; return $_ } | ` Export-CSV c:\awsaf\powershell\afterX.csv -Delimiter ',' -NoTypeInformation
powershell
Awsaf
source share