I am new to powershell and I having a little dilemma with a script I created to compare two csv files. The first csv has only one column called "Database Name" in it. The secound csv has a many columns and I only care about two of them "Database Name" and "Host Name". Right now the script compares only the "Database Name" column which works great!! and exports to Differences.csv. However, I would also like to see the corresponding "Hostname" column for each "Database Name" in the difference file.
$northdb = Import-Csv -Path ".\northdb.csv" -Header "Database Name" | Sort-object Property "Database Name" -Unique
$sdb = Import-Csv ".\Current\SQLDatabaseInventory.csv" -Header "hostname",h2,h3,h4,h5,"Database Name" |Sort-Object -Property "Database Name" -Unique
Compare-Object $northdb $sdb -Property "Database Name" | Where-Object{$_.SideIndicator -eq '=>'} |
Select-Object "Database Name" | export-csv .\Difference.csv -NoTypeInfo
Please assist