Nested PowerShell-CustomObjects (JSON)

Aus Wiki-WebPerfect
Version vom 19. Dezember 2018, 11:03 Uhr von Admin (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

How do I create a nested PowerShell custom object to store layers (nested) of information?
Use a hashtable with the PSCustomObject type accelerator, and specify PSCustomObject as the value to the Property Name (Key)


$JSON = [PSCustomObject]@{
    Property1NameLayer1 = [PSCustomObject]@{ 
        Property2NameLayer2 = [PSCustomObject]@{
            Property3NameLayer3 = 'Property3Value'
        }
        Property4NameLayer2= 'Property2Value'
        Property5NameLayer2= 'Property3Value'
    }
} | ConvertTo-Json
</souce>
 
 
 
 
[[Kategorie:PowerShell]]