Comparing and exporting the difference from csv file

Please HELP

I have a task in hand where i need to copy ExtensionAttribute14 to 9. This needs to be a script which i can run daily with the Task Scheduler. I need to ensure that this script does not consume much resources. The domain has around 80000 users.

I have exported the data in csv file that includes the SamAccountName,ExtensionAttribute14 and ExtensionAttribute9 with the below one liner.

$data1 = Get-ADUser -SearchBase “DC=xyz,DC=com” -LDAPFilter ‘(extensionAttribute14=*)’ -Properties * | Select-Object SamAccountName,extensionattribute14,extensionattribute9

$data1 | Export-csv C:\users\User1\Documents\data1.csv -NoTypeInformation

Now i need to compare Values in extensionattribute14 and extensionattribute9 in this csv file and create a new csv file with the difference. Then i need use the new csv file that has the difference and copy the value from extensionattribute14 to extensionattribute9 from this new CSV file.

Please help with this.

So, extensionattribute14 and extensionattribute9 should always be identical?
Why compare them in the first place?

After you exported the information you simply could do this:

foreach ($item in $data1){
    $item.extensionattribute14 = $item.extensionattribute9
}

I am pretty shure this is less ressource consuming than comparing and changing only objects which show a difference.

Thanks for your response Manuel.

Unfortunately it did not work. I have to say that i am relatively a new beginner in PowerShell. Could you please assist with the complete script please.