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

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „''How do I create a nested PowerShell custom object to store layers (nested) of information?'' <br> ''Use a hashtable with the PSCustomObject type accelerator,…“)
 
K (Admin verschob die Seite Nested PowerShell-Objects nach Nested PowerShell-CustomObjects (JSON), ohne dabei eine Weiterleitung anzulegen)
 
(Eine dazwischenliegende Version des gleichen Benutzers werden nicht angezeigt)
Zeile 13: Zeile 13:
 
     }
 
     }
 
} | ConvertTo-Json
 
} | ConvertTo-Json
</souce>
+
</source>
  
  

Aktuelle Version vom 19. Dezember 2018, 12: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