Я пытаюсь экспортировать свои результаты из объекта сравнения в csv, но получаю сообщение об ошибке при экспорте. Это выглядит нормально, когда я просто вызываю его в Excel. Я предполагаю, что всякий раз, когда выводится более одного значения, вместо значения помещается ошибка.
Вот мои файлы csv в прошлом.csv
VKEY
V-12345
V-23456
V-1111
текущий.csv
VKEY
V-12345
V-6789
V-23456
V-256
Мой новый csv должен сказать
Past, Current
V-6789,V-1111
V-256
То, что я получаю сейчас, это
Past, Current
System.Object[],@{vkey=V-1111}
.
$Past = Import-CSV "past.csv"
$Current = Import-CSV "Current.csv"
$pastchange = Compare-Object $Past $Current -Property vkey | Where-Object {$_.SideIndicator -eq '=>'} | Select-Object VKEY
$currentchange = Compare-Object $Past $Current -Property vkey | Where-Object {$_.SideIndicator -eq '<='} | Select-Object VKEY
$obj = New-Object PSObject
$obj | Add-Member NoteProperty Past $pastchange
$obj | Add-Member NoteProperty Current $currentchange
$obj | Export-Csv "ChangeResults.csv" -NoTypeInformation