Compare Master file and output files

I am trying to compare a Master Template to a CSV file that is ran daily to check if such machines are getting backed up or not and than output the file with the machines not getting backed up. I have tried the compare cmdlet in PowerShell and I don't get an accurate read.

$BaseCSV=import-csv .\documents\reports\Odin.csv

$NewCSV=import-csv .\Documents\Reports\thor.csv

Compare-Object -ReferenceObject $BaseCSV -DifferenceObject $NewCSV -IncludeEqual -property Node | Where { $_.SideIndicator -eq '=>' -or $_.SideIndicator -eq '==' } | export-csv .\Documents\Reports\Results\data.csv -NoTypeInformation

I have also tried to link my PowerShell commands to my sql database to try and compare the differences but I'm getting no where. I'm new to trying to compare this but any help would be great.

  • You are not providing enough info to go on.

     

    What does this Master Template and CSV look like

     

    What does this …

     

    ‘I have tried the compare cmdlet in PowerShell and I don't get an accurate read.’

     

    … mean? What are you expecting? You don’t show that either.

     

    Ditto on this…

     

    ‘I have also tried to link my PowerShell commands to my sql database to try and compare the differences’

     

    … how, does this SQL thing effort have anything to do with the Master Template and CSV?

    Is that where the Master Template and or CSV come from, etc…

  • here is my powershell script

    $MasterFile = import-csv .\Documents\Reports\Odin.csv | % {$hash = @{} } { $hash["$($_.NODE)"] = $_}
    $CompareFile = import-csv .\documents\reports\Hermitage1128.csv

    $CompareFile | foreach {$COMPUTERNAME = $hash[$_.NODE]

    if (!($Computername))

    {"not found"}

    else
    {"found"}

    }

    as you can see one is my master file and the other is the compare file. when I run this i dont get the output im looking for and Im trying to get it to out put the differneces in the csv files. thoughts?