Powershell: Trying to combine two arrays that don't use the same columns -


I have two arrays imported from a CSV file, from here I will refer to the master array and the update array . / P>

There are three additional columns on the front of the master array and three additional columns on the back.

Every day I get a new update array, which I have to do with two things. / P>

A) Remove any rows on the master which do not appear in the update

b) Add any rows that appear in the update, but the master does not master

I am still quite new in the powershell, and in general (mostly self-taught) the script and how to find out this can not know I know that there is a comparison-object command, Can get a list of I am the one who gets the lines very easily, but I am not sure how to combine them the way I want them.

Edit: Master array entries have this information:

ef: true
ea: true
rem: true
accountname: example1
enabled Gone: Set the correct password password: 01/08/2002 13: 14:19
When did: 01/08/2002 13:14:19
Description:
Owner Email: johnsmith@email.com
given name: John
sn: Smith
Manager: John Doe - Level 2: Person 1
Level 3: Person 2
Level 4: Person 3

Only when updated:

Account name: example1
Enable: True - Password list: 01/08/2002 13:14:19
WHEN: 01 / 08/2002 13:14:19 above Name:
Owner Email: johnsmith @ Email .com
given name: John
sn: Smith
Manager: John Doe

The account name column can be used together as a unique key which combines two arrays together, you can use it below Everything like a script creates a third array and then overwrites the master ARS CSV once completed.

  $ arrmaster = import-csv c: \ temp \ arrmaster.csv $ arrupdate = import-csv c: \ temp \ arrupdate.csv $ arrworking = @ () foreign currency ($ line $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Cache Accountname] "} If ($ rowmaster.Count -gt 1) {Duplicate record found for write-debug" $ ($ row.accountname) "} $ Rowmaster.Count -q1) {$ rowworking = "" | "owner of email", given name, sn, manager, level 2, level 3, level 4 $ rowworking.ef = $ rowmaster.ef $ Choose rowworking.ea = $ rowmaster, select F, AA, RIM, AccountName, Enabled, PasswordState, When, Description. Ea $ rowworki Ng.rem = $ rowmaster.rem $ rowworking.accountname = $ rowupdate.accountname $ rowworking.Enabled = $ rowupdate.Enabled $ rowworking.PasswordLastSet = $ rowupdate.passwordLastSet $ ​​rowworking.whencreated = $ linewidth. Description = $ Rowupdate.Description $ rowworking. "Owner Email" = $ rowupdate. "Owner email" $ rowworking.givenname = $ rowupdate.givenname $ rowworking.sn = $ rowupdate.sn $ rowworking.manager = $ rowupdate.manager $ rowworking. Level2 = $ rowmaster.Level2 $ rowworking.Level3 = $ rowmaster.Level3 $ rowworking.Level4 = $ rowmaster.Level4 $ arrring + = $ line work}} $ arrworking | Export-CSV-Force - Nautification C: \ Temporary \ arrma.csv    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -