Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

compare 2 csv file and output new file

$
0
0

Hello

I have 2 csv file that i need to compare and output to a new txt file. Logic is if execlusion.csv list match sms.csv list, delete from sms.csv and write it to result.txt file. As example below, i am trying to get the value of (aaa4, aaa5, aaa6, aaa7,aaa8)

but i am getting (zzzz1,zzz2,asdf3,asdf4,tqer3,aaa4,aaa5,aaa6,aaa7,aaa8).. Please help.

$smscsv = import-csv C:\temp\sms.csv
$execusioncsv = import-csv C:\temp\exclusion.csv
$result = Compare-Object -ReferenceObject $smscsv.'computer name' -DifferenceObject $execusioncsv.'computer name' |% {$_.inputobject} | out-file c:\temp\result.txt

SMS.CSV

Computer NameLast Logged OnHardWare ModelIP Address
aaa1bob1hp123.1.1.1
aaa2bob2hp123.1.1.2
aaa3bob3hp123.1.1.3
aaa4bob4hp123.1.1.4
aaa5bob5hp123.1.1.5
aaa6bob6hp123.1.1.6
aaa7bob7hp123.1.1.7
aaa8bob8hp123.1.1.8
aaa9bob9hp123.1.1.9
aaa10bob10hp123.1.1.10

EXECLUSION.CSV

Computer Name
aaa1
aaa2
aaa3
zzzz1
zzz2
asdf3
asdf4
tqer3
aaa9

aaa10


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>