Powershell script to compare two txt files and create 3rd txt file with differences

I have two .txt files. One is with up to date 2 different NIC drivers brand and up to date versions that I will maintain manually:
DriverDesc     : Realtek PCIe GBE Family Controller
DriverDate     : 6-18-2013
DriverVersion  : 7.73.618.2013

DriverDesc     : Intel(R) 82579LM Gigabit Network Connection
DriverDate     : 5-15-2013
DriverVersion  : 12.6.45.0


and one .txt file with columns like:


PSComputerName : PC1
DriverDesc     : Intel(R) 82579LM Gigabit Network Connection
DriverDate     : 5-15-2013
DriverVersion  : 12.6.45.0

PSComputerName : PC2
DriverDesc     : Realtek PCIe GBE Family Controller
DriverDate     : 6-18-2013
DriverVersion  : 7.73.618.2013

PSComputerName : PC3
DriverDesc     : Realtek PCIe GBE Family Controller
DriverDate     : 6-18-2013
DriverVersion  : 7.73.618.2013

PSComputerName : PC4
DriverDesc     : Intel(R) 82579LM Gigabit Network Connection
DriverDate     : 10-31-2012
DriverVersion  : 12.2.45.0

PSComputerName : PC5
DriverDesc     : Intel(R) 82579LM Gigabit Network Connection
DriverDate     : 5-15-2013
DriverVersion  : 12.6.45.0

How do I create a script in PowerShell that will match "DriverDesc" between two .txt files, when it finds the match, compare "DriverVersion" field. If "DriverVerison" matches between two proceed with next one, if it doesn't grab the "PSComputerName" and below fields (DriverDesc, DriverDate, DriverVersion) and create separate (3rd)  .txt file that will have all the fields like second .txt file but just the PC's that are  not up to date with NIC drivers?
MRSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
If your text files are .CSVs then it's not too hard.  I'm attaching the files in that format.
$driverComp =  (Import-CSV diff.csv)
@(foreach ($ref in (Import-CSV ref.csv))
{
    foreach ($diff in $driverComp)
    {
        If ($ref.DriverDesc -eq $diff.DriverDesc)
        {
            If ($ref.DriverVersion -ne $diff.DriverVersion)
            { $diff }
        }
    }
}) | Export-CSV OutofDate.csv -notype

Open in new window

diff.csv
ref.csv
0
footechCommented:
Here's another way to write it out which is a bit better.
$driverComp = Import-CSV diff.csv
@(foreach ($item in (Import-CSV ref.csv))
{
    $driverComp | Where { $item.DriverDesc -eq $_.DriverDesc -and $item.DriverVersion -ne $_.DriverVersion }
}) | Export-CSV OutofDate.csv -notype

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MRSAuthor Commented:
You rock! Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.