I think this code looks convoluted and messy… and I like clean code
My question, to paraphrase one of my favorite films is: “is this as good as it gets?”
There are a few ways to write it, but with an object structured in that fashion, that’s about it. A more pipelined version might be something like this:
$Json | ConvertFrom-Json |
ForEach-Object {
foreach ($Name in $_.Value.PSObject.Properties.Name) {
[PSCustomObject]@{
Name = $Name
Days_Remaining = $_.$Name.Days_Remaining
}
}
}
test
get-command