Storing data items in generic list PSobject

$List = [System.Collections.Generic.List[Object]]::new(); 
 
 $ListItem  = [PSCustomObject][Ordered]@{ 
    FieldName = $SomeValue       
    OtherFieldName = "SomeValue"
    YetAnotherFieldName = $true

 }
 
$List.Add($ListItem) 

$List = [System.Collections.Generic.List[Object]]::new();

$ListItem = [PSCustomObject][Ordered]@{
FieldName = $SomeValue
OtherFieldName = “SomeValue”
YetAnotherFieldName = $true

}

$List.Add($ListItem)

Leave a Comment