Comparing and exporting the difference from csv file

Welcome Forums General PowerShell Q&A Comparing and exporting the difference from csv file

This topic contains 3 replies, has 2 voices, and was last updated by

 
Participant
1 year, 11 months ago.

  • Author
    Posts
  • #66513

    Participant
    Points: 0
    Rank: Member

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

    Participant
    Points: 38
    Rank: Member

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

  • #66525

    Participant
    Points: 38
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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.

The topic ‘Comparing and exporting the difference from csv file’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort