If you want to check the certificate status for server, below is the script for that.
$ScriptBlockContent ={param ($Location)
Set-Location $Location
$certs =get-childitem
$certarr=@()
foreach ($cer in $certs )
{
$Error.Clear();
$arr+=[pscustomobject]@{ Location=$Location
isCertValid=$cer |Test-Certificate;
Cause=$Error[0];
thumbprint= $cer.Thumbprint;
Name=$cer.FriendlyName
Subject=$cer|select -expand subject
SubjectName=$cer.SubjectName
SignatureAlgorithm=$cer.SignatureAlgorithm
SerialNumber=$cer.SerialNumber
PublicKey=$cer.PublicKey
Issuer=$cer.Issuer
IssuerName=$cer.IssuerName
NotAfter=$cer.NotAfter
}
}
$certarr
}
$Location=’Cert:\LocalMachine\My’
$certlist=Invoke-Command -ComputerName ‘Server1′,’Server2’ -ScriptBlock $ScriptBlockContent -ArgumentList $Location
$certlist | ?{$_.isCertValid -eq $false}|Out-gridview
Regards,
Chaitanya