PowerShell: Output Windows Services to JSON file

A simple one-liner for outputting Windows Service properties to a JSON file.

Get-Service * | ConvertTo-Json | Out-File services.json

And here are some approaches for getting string representations of the enum integers:
[Stack Overflow] Powershell – Retain Complex objects with ConvertTo-Json


Alternative command using Get-WmiObject — this doesn’t require any enum serialisation workarounds:

Get-WmiObject win32_service | ConvertTo-Json > services.json