Comparing 2 csv different csv files

1st CSV file

2nd CSV file
ServerName,MODEL,OS,ARCHITECTURE,RAMinMB,CPU,SPEEDinGHz,PHYSICAL,CORE,Drive1,Drive2,VMware Virtual Platform,Microsoft Windows Server 2012 R2 Standard,64-bit,2767,Intel64 ,2.4,8,1,C:49.51,D:100.00

I need to compare the RAMinMB of 2nd csv file with the first csv file BaseMemory, if there is any change then write the present value in 2nd csv file and all the data of 2nd csv file to a 3rd csv file.

below is my sample code which I am trying to do through. Nothing seems to be getting captured.
###########Script #########
$BaseCSV = import-csv -Path “D:\2nd.csv”
$NewCSV = import-csv -Path “D:\1st.csv”

$output = @()
forEach ($Column in $BaseCsv) {
$result = $NewCSV | Where-Object {$Column.ARCHITECTURE -eq $_.ARCHITECTURE}

$output += New-object PSObject -property @{

ServerName = $Column.ServerName
Model = $Column.Model
OS= $Column.OS
Architecture= $Architecture


$output | select-object SERVERNAME,MODEL,SERIAL,OS,ARCHITECTURE| Export-Csv -Path “D:\TestCompare\change.csv” -NoTypeInformation -Force

Are you trying to replace the system architecture or RAMinMB. You stated you were looking to compare the respective Memory columns in your two CSVs, but your code only compares Architecture. Additionally, can you confirm the CSV format of the 1st CSV? Right now your 1st CSV format would result like this:

ApplicationName : SCOMLAB
C:DriveSpace : 49
D:DriveSpace : 100
ProcessorCount : 1
CoreCount : 2
BaseMemory : 8192
BaseOU : PriyaLAB
ApplicationVersion : 7.1
PatchList : a

Because the Architecture in your first CSV is = b, your code is not finding a match in $result = $NewCSV | Where-Object {$column.ARCHITECTURE -eq $_.ARCHITECTURE}. So $result is empty.

You may also want to check out the Join-Object function (

Sorry, I also just noticed you are setting ARCHITECTURE value to $Architecture which is never defined so is also empty. We can provide pointers on how to remedy these, but we will need to understand what exactly you are trying to accomplish.


Sorry , My bad.
I sorted it out. The data in the csv file was not correct. The data a,b,c has to be a single value. So i just twigged the csv input. And now I am successfully measure the objects.