电源外壳。增加CSV文件或数组的值

时间:2013-09-04 12:57:59

标签: arrays powershell csv

我的CSV文件如下:

Initials,Size excl. Backup/Pst,Number of warnings
USER1,100,1
USER2,100,1
USER4,400,2

我想将值“警告数量”增加1,这样我最终会得到:

Initials,Size excl. Backup/Pst,Number of warnings
USER1,100,2
USER2,100,2
USER4,400,3

我试过了,但没有成功。
我也尝试将它放在数组中,但无法使其正常工作。

$Temp = Import-Csv $Database | foreach {$_.'Number of warnings' +1}

但这有两件事:
只在数字的末尾加1,所以1变为11,2变为21(因为它是一个字符串)
输出只是“警告数量”列 - 我的其他信息似乎消失了

1 个答案:

答案 0 :(得分:1)

这有效:

$myreport = Import-Csv .\testing.csv

$myreport | %{$_.'Number of warnings' = 1 + $_.'Number of warnings'}