Commands / Text and objects

ConvertTo-Json

Turn objects into JSON

beginner Text and objects

ConvertTo-Json
 Get-ChildItem -File | Select-Object Name, Length | ConvertTo-Json
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: ConvertTo-Json

Makes JSON. For nested data, add -Depth 5 (or higher). Without it, anything deeper than 2 levels is cut off and shown as type names. Windows PowerShell 5.1 does this silently.

Try this

Get-Date | ConvertTo-Json

Related commands