i have 2 csv's with below details
csv1:
LNX_HOST_NAME IPAddress HOST_ID SERVER_TYPE
------------- --------- ------- -----------
head01.com 10.16.0.11 ABI WB
head02.com 10.16.0.12 ABI WB
head03.com 10.16.0.14 ABI WB
csv2:
Lastboot IPAddress SystemUpTime OSType
-------- --------- ------------ ------
2/29/2020 3:28:00 AM 10.16.0.10 2698626.75 Unix
2/29/2020 3:29:00 AM 10.16.0.11 2698560.75 Unix
2/29/2020 3:34:00 AM 10.16.0.12 2698200.5 Unix
Have to compare the IPAddress column from both the csv and return the common records like below
HOST_NAME IPAddress HOST_ID SERVER_TYPE SystemUpTime
------------- --------- ------- ----------- -------------
head01.com 10.16.0.11 ABI WB 2698560.75
head02.com 10.16.0.12 ABI WB 2698200.5
Need help to get the logic for this.i wrote the below code which is giving me the unique records, but not able to get the UpTime column
$Reference = Import-Csv -Path "D:\Script\csv2.csv" | Select-Object -Skip 1
$Difference = Import-Csv -Path "D:\Script\csv1.csv" | Select-Object -Skip 1
$keys = $Reference | ForEach-Object -MemberName IPAddress | Select-Object -Unique
$DiffVal = $Difference | Where-Object -FilterScript {$keys -Contains $_.IPAddress}