Created
September 19, 2018 20:45
-
-
Save luksi1/366759b14cc50193d5fdb6d9ed56a571 to your computer and use it in GitHub Desktop.
PowerShell JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$json = '[{ | |
"certname": "foo.domain.com", | |
"environment": "production", | |
"name": "keystores", | |
"value": { | |
"/usr/local/cert/foo.jks:foo": { | |
"days_remaining": 396, | |
"issuer": "C=COM O=Foo Co. CN=Foo Type 3 CA v1", | |
"owner": "C=COM L=Rome O=Vatican CN=pope.domain.com" | |
} | |
} | |
}, | |
{ | |
"certname": "bar.domain.com", | |
"environment": "production", | |
"name": "keystores", | |
"value": { | |
"/usr/local/cert/bar.jks:bar": { | |
"days_remaining": 396, | |
"issuer": "C=COM O=Foo Co. CN=Foo Type 3 CA v1", | |
"owner": "C=COM L=Washington D.C. O=White House CN=trump.domain.com" | |
}, | |
"/usr/local/cert/poo.jks:poo": { | |
"days_remaining": 396, | |
"issuer": "C=COM O=Foo Co. CN=Foo Type 3 CA v1", | |
"owner": "C=COM L=London O=Buckingham Palace CN=elizabeth.domain.com" | |
} | |
} | |
}]' | |
foreach ($i in $($json | convertfrom-json).value) { | |
foreach ($n in $($i.psobject.properties).name) { | |
[PSCustomObject]@{ | |
name = $n; | |
days_remaining = $i.${n}.days_remaining | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment