Powershell: Compare 2 files

Hello Experts,

I need some help with a script to compare 2 files. User not listed in FileB should be the output as shown below.

FileA

Description, User, mail
TestUser1,tuser1,tuser1@abc.com
TestUser2,tuser2,tuser2@abc.com
TestUser5,tuser5,tuser5@abc.com


FileB

User
tuser2

The results should be:
TestUser1,tuser1,tuser1@abc.com
TestUser5,tuser5,tuser5@abc.com

Your assistance is much appreciated.
Parity123Asked:
Who is Participating?
 
oBdACommented:
$usersB = Import-Csv -Path C:\Temp\FileB.csv | Select-Object -ExpandProperty User
Import-Csv -Path C:\Temp\FileA.csv | Where-Object {$usersB -notcontains $_.User} | Export-Csv -NoTypeInformation -Path C:\Temp\NotInB.csv

Open in new window

1
 
Parity123Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.