Forgive me, but I do not know the correct terminology for this.
Assuming the following hash table:
$ConfigurationData = @{
    AllNodes = @(
        @{
            NodeName="*"
            PSDscAllowPlainTextPassword=$True
            PsDscAllowDomainUser=$True
        }
    )
}
How to do this:
$ConfigurationData = @{
    AllNodes = @(
        @{
            NodeName="*"
            PSDscAllowPlainTextPassword=$True
            PsDscAllowDomainUser=$True
            NewItem = "SomeNewValue"
            AnotherNewItem = "Hello"
        }
    )
}
I can do:
$ConfigurationData.AllNodes += @{NewItem = "SomeNewValue"}
$ConfigurationData.AllNodes += @{AnotherNewItem  = "Hello"}
And the execution $ConfgurationData.AllNodeslooks right:
$ConfigurationData.AllNodes
Name                           Value                                                                                                                                            
----                           -----                                                                                                                                            
NodeName                       *                                                                                                                                                
PSDscAllowPlainTextPassword    True                                                                                                                                             
PsDscAllowDomainUser           True                                                                                                                                             
NewItem                        SomeNewValue                                                                                                                                     
AnotherNewItem                 Hello  
But converting it to JSON tells a different story:
$ConfigurationData | ConvertTo-Json
{
    "AllNodes":  [
                     {
                         "NodeName":  "*",
                         "PSDscAllowPlainTextPassword":  true,
                         "PsDscAllowDomainUser":  true
                     },
                     {
                         "NewItem":  "SomeNewValue"
                     },
                     {
                         "AnotherNewItem":  "Hello"
                     }
                 ]
}
NewItemand AnotherNewItemare in their own hash table, not in the first one, and this causes the DSC to throw shaky:
ValidateUpdate-ConfigurationData : all elements of AllNodes need to be hashtable and has a property NodeName.
I can do the following which gives me the correct result:
$ConfigurationData = @{
    AllNodes = @(
        @{
            NodeName="*"
            PSDscAllowPlainTextPassword=$True
            PsDscAllowDomainUser=$True
        }
    )
}
foreach($Node in $ConfigurationData.AllNodes.GetEnumerator() | Where-Object{$_.NodeName -eq "*"}) 
{
            $node.add("NewItem", "SomeNewValue")
            $node.add("AnotherNewItem", "Hello")
}
$ConfigurationData | ConvertTo-Json
{
    "AllNodes":  [
                     {
                         "NodeName":  "*",
                         "PSDscAllowPlainTextPassword":  true,
                         "NewItem":  "SomeNewValue",
                         "AnotherNewItem":  "Hello",
                         "PsDscAllowDomainUser":  true
                     }
                 ]
}
But this seems redundant compared to a type string $ConfigurationData.AllNodes += @{NewItem = "SomeNewValue"}
I also tried and failed with:
$ConfigurationData.AllNodes.GetEnumerator() += @{"NewItem" = "SomeNewValue"}
Is there a similar way to target the right “element”?