Answer the question
In order to leave comments, you need to log in
How to pass two variables from a query to PowerShell?
Good day!
There is a script that looks at certificates in a directory and outputs them in JSON:
$certsname = Get-ChildItem -Path Cert:\LocalMachine\AuthRoot | Select FriendlyName,Thumbprint
$idx = 1
write-host "{"
write-host " `"data`":[`n"
foreach ($currentcert in $certsname)
{
if ($idx -lt $certs.count)
{
$line= "{ `"{#CERTID}`" : `"" + $currentcert + "`" },"
write-host $line
}
elseif ($idx -ge $certs.count)
{
$line= "{ `"{#CERTID}`" : `"" + $currentcert + "`" }"
write-host $line
}
$idx++;
}
write-host
write-host " ]"
write-host "}"
{
"data":[
{ "{#CERTID}" : "@{FriendlyName=GeoTrust; Thumbprint=GDSFGDFG32134SADSAD}" },
{ "{#CERTID}" : "@{FriendlyName=DigiCert; Thumbprint=DSAD124DASDA23123}" },
{ "{#CERTID}" : "@{FriendlyName=The USERTrust NetworkT; Thumbprint=FASDF123123FASD3}" }
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question