I have this foreach :
Foreach($Cert in $CertSame) {
Foreach( $ChildCert in Get-Childitem –path Cert:\LocalMachine\My\$($Cert.thumbprint)) {
$ChildCert | Select-Object -Property Subject,@{n=’ExpireInDays’;e={($_.notafter – (Get-Date)).Days}}
}
}
The return is
Subject ExpireInDays
------- ------------
CN=*.x.be 311
CN=*.x.com 74
I need to save the subject in a variable, and the days in another variable.
Thanks for your help.
CodePudding user response:
You can try this -
$Variable = $ChildCert | Select-Object -Property Subject,@{n=’ExpireInDays’;e={($_.notafter – (Get-Date)).Days}};
$Subject = $Variable.Subject;
$ExpireInDays = $Variable.ExpireInDays;