Renam or Merge Array Properties

Welcome Forums General PowerShell Q&A Renam or Merge Array Properties

Viewing 4 reply threads
  • Author
    Posts
    • #208977
      Participant
      Topics: 3
      Replies: 4
      Points: 43
      Rank: Member

      Good Morning from the UK.

       

      I’ve got an Array in Powershell that I’ve managed to add to using my code.  It looks like this:

      Groups : {0, 1}
      Success : True
      Name : 0
      Captures : {0}
      Index : 173
      Length : 40
      Value : 700
      ID:erui5746

      Groups : {0, 1}
      Success : True
      Name : 0
      Captures : {0}
      Index : 248
      Length : 36
      Value : 800
      ID:erui5745

      Groups : {0, 1}
      Success : True
      Name : 0
      Captures : {0}
      Index : 323
      Length : 35
      Value : 900
      ID:erui5743

       

      In my array which is called $arr1 I need the properties ‘Value’ and ‘ID’ to be under the same, new property called MyValue.

      I’ve tried (foreach $a in $arr1){$arr2+=$a} to add the properties into a new array

      But I still end up with ID and Value just in another array. I need to merge ID and Value properties into a single property.

       

      Any help would be great

      • This topic was modified 10 months, 3 weeks ago by ajtsystems76.
    • #208986
      Participant
      Topics: 12
      Replies: 547
      Points: 1,345
      Helping Hand
      Rank: Community Hero
    • #208989
      Participant
      Topics: 10
      Replies: 2480
      Points: 6,537
      Helping Hand
      Rank: Community MVP

      Id would have been helpful to know how you created this array of hastables. And please format your code and sample data and console output as code using the code tags named “PRE“. Thanks.

    • #209115
      Participant
      Topics: 3
      Replies: 4
      Points: 43
      Rank: Member

      awesome, worked perfectly.

       

      Thanks for your help!

    • #209127
      Participant
      Topics: 10
      Replies: 2480
      Points: 6,537
      Helping Hand
      Rank: Community MVP

      awesome, worked perfectly.

      I’m curious. Which approach do you mean? They should work both. 😉

Viewing 4 reply threads
  • The topic ‘Renam or Merge Array Properties’ is closed to new replies.