Comparing and exporting the difference from csv file

This topic contains 3 replies, has 2 voices, and was last updated by  Deven Suji 1 year, 2 months ago.

  • Author
  • #66513

    Deven Suji

    ***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.

  • #66522


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

  • #66525


    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.

  • #66564

    Deven Suji

    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.

You must be logged in to reply to this topic.