$outFile = "C:\PS logs\Outlook_autofill\test.csv"
$tests = Import-Csv -Header username,firstname,surname,pcname,5,6,7,8,9,10,11,12,13,14,15 $outFile |
sort -property @{Expression="username";Descending=$true}, @{Expression="pcname";Descending=$false}
$tests[0]
for ($i=1; $i -le $tests.length -1; $i++)
{
if ($tests[$i]."username" -eq $tests[$i-1]."username" -AND $tests[$i]."pcname" -eq $tests[$i-1]."pcname")
{
continue
}
else {$tests[$i]}
}我设法从互联网上的一个网站上下载了代码,并使其工作,它似乎做了我想做的事情。但是,我不确定如何将其输出回CSV?我可以把输出行和continue放在同一个循环中吗?谢谢你的帮助。
发布于 2020-03-03 18:25:22
您可以在循环中使用此结构将每一行添加到所需的文件中。
$NewLine = "{0},{1},{2}" -f $ValueForColumn1, $ValueForcolumn2, $ValueForcolumn3
Add-Content -Path $PathToFile -Value $NewLine https://stackoverflow.com/questions/60504719
复制相似问题