none
Add new key value in system.array using powershell RRS feed

  • Question

  • I have object $var=@{}

    $var is fixed collection array

    I want to add element PIN where location say Dallas, different PIN as per location

    I have PIN array $PIN= @("411014","411004") I want to add PIN[0] where location is Dallas and PIN[1] where location

    is Utah

    I have tried as declare [system.collection.arraylist]$var and then adding $var+=, but it wont added

    in expected output if location is Dallas then add 411014 else if location is Utah then add 411004 this way I want to add nodes

    $var= Name :Jerry Megan address : forthworth mobile :111-111-1111 location : Dallas Name :Mery Slogan address : Pericili mobile :111-211-1111 location : Utah

    $var.gettype()

    IsPublic IsSerial Name BaseType

    -------- -------- ---- --------

    True True Object[] System.Array

    #final output expected 
    $var=
    
    Name :Jerry Megan
    address : forthworth
    mobile   :111-111-1111
    location : Dallas
    PIN: 411014
    
    Name :Mery Slogan
    address : Pericili
    mobile   :111-211-1111
    location : Utah
    PIN: 411004
    


    Thursday, November 19, 2020 6:52 PM

Answers

All replies