I am trying to check if a particular certificate is installed on my machine. I am using the following powershell script
SET-LOCATION CERT:\LOCALMACHINE\my
$certificate = "CN=*XXXX"
$ListOfCertificate = GET-CHILDITEM | Select-Object -Property Subject
$ListOfCertificate.ForEach({if($_==$certificate) {Write-Output "Certficate Successfully Installed"} })
ListOfCertifiacte Object looks like this:
Thumbprint Subject
---------- -------
yu39B5646D569XXXXXX
ui05F79VVVVVVVVVV CN=*XXXX
6kj6A3AAAAAAAAAAAA CN=XXXXXXXX
1ygfA1NNNNNNNNNNNN CN=XXXXXXXX
I just want to loop through this list and check if Subject Property Contains "*XXXX" value. But the above code is not working.its throwing error saying $certifiacte is not recognized as a cmdlet or script. what i am doing wrong?