Skip to content

Instantly share code, notes, and snippets.

@luksi1
Created September 19, 2018 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luksi1/366759b14cc50193d5fdb6d9ed56a571 to your computer and use it in GitHub Desktop.
Save luksi1/366759b14cc50193d5fdb6d9ed56a571 to your computer and use it in GitHub Desktop.
PowerShell JSON
$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