Automation · PowerShell Automation
JSON
Cheat sheet · https://pcornel.dk/topic.php?topic=5251
Answer
PowerShell handles JSON with ConvertFrom-Json to turn text into objects and ConvertTo-Json -Depth to serialize, since the default depth of 2 silently truncates nested data.
Remember
- ConvertFrom-Json turns text into objects.
- ConvertTo-Json -Depth avoids truncation.
- Default depth of 2 silently cuts nested data.
First checks
Get-Content f.json -Raw | ConvertFrom-Json— parse$obj | ConvertTo-Json -Depth 10— serialiseTest-Json -Json $json -Schema $schema— validate (PS 7)
Verify in this order
JSON ↔ PowerShell objects
Where it usually breaks
Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.
JSON · PowerShell operational reference
| Boundary | JSON reference |
|---|---|
| Runtime identity | PowerShell edition/version + command/module source |
| Persistent intent | Script/module/config prerequisites under source control |
| Verification | Read-only discovery → execution evidence → independent target read-back |
| Output contract | Structured objects/streams before formatting |
| Failure boundary | Separate engine/binding from transport/API/native and target-state failures |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5251