Reputation: 13
Today i was trying to search a method for "skip" the password when it is requested. Is there a way for do this or for do similar things, like put automatically a random password when requested?
Get-PfxCertificate "c:\path\file"
Thumbprint Subject
---------- -------
**************************************** CN=****************
**************************************** CN=****************
Password: (example: random)
(I know that if you put a random password I will get an error but I do not care.)
Upvotes: 1
Views: 1289
Reputation: 174485
You could attempt to load the certificate file without providing a password and suppress any exceptions thrown:
foreach($PfxFile in Get-ChildItem C:\Path\to\cert\files -Filter *.pfx) {
try {
[System.Security.Cryptography.X509Certificates.X509Certificate2]::CreateFromCertFile($PfxFile.FullName)
}
catch {
continue
}
}
Upvotes: 1