Reputation: 1084
Right after a certificate is installed (KeyFactor's Signum is used on Windows 11), the Test-Path
cmdlet of powershell doesn't work properly. For example, if the following code runs on the same powershell window, it prints Certificate is Not Installed
(Here, '...' mean some more characters)
if (Test-Path -Path "Cert:\LocalMachine\My\BB7D...5DF3") {
Write-Host "Certificate is installed"
} else {
Write-Host "Certificate is NOT installed";
}
When I do cd cert:\LocalMachine\My\
and dir
, then there is no such thumbprint as expected.
BUT when I try to sign a file using the certificate, it works.
What is more strange is that if I open a new powershell and run the if statement block above, it reports that Certificate is installed
and yes, signing works good. So, it looks like that powershell is using some kind of caching mechanism to check for the path for cert:
space, and the Test-Path
cmdlet sometimes reports the wrong result.
Also the opposite could happen: by running some command to remove the certificate, another opened powershell window still reports that certificate is found in the specified cert: path.
Could you explain why this is happening (with succinct explanation) and how to make the Test-Path
cmdlet reports the correct result?
Upvotes: 0
Views: 20