Nested PowerShell-CustomObjects (JSON): Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
K
K (Admin verschob die Seite Nested PowerShell-Objects nach Nested PowerShell-CustomObjects (JSON), ohne dabei eine Weiterleitung anzulegen)
 
(kein Unterschied)

Aktuelle Version vom 19. Dezember 2018, 11:04 Uhr

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