active_directory
active_directory copied to clipboard
Let an array with a single entry be an array in JSON
If the the "groups" property of the "user" object has only one entry, and we want to convert our list of users to JSON, then PowerShell doesn't create an array with a single entry as the value for the "group" property, but instead a scalar – a simple string.
The Problem is that PowerShell uses a default traversal depth of 2, if we use ConverTo-Json.
We fix our issues by using a greater traversal depth with the Argument -Depth:100.
https://stackoverflow.com/questions/53583677/unexpected-convertto-json-results-answer-it-has-a-default-depth-of-2