I’m attempting to create a ps script to import .pfx certificates into the CurrentUser store. The script will be executed at logon by about 30 individuals. Each user has a specific folder path where their certificate is stored, but the certificate names don’t match their logon id. I’m trying to use a wild card in the -FilePath statement to locate the file, but I keep getting a message that the file can’t be found; Import-PfxCertificate : The PFX file could not be found.
Is there a way (better way) to select a .pfx file using wild card notation? Thank you;
$PlainTextPass = “xxxx”
$pfxpass = $PlainTextPass |ConvertTo-SecureString -AsPlainText -Force
Import-PfxCertificate -FilePath C:\temp$env*.pfx cert:\CurrentUser\my -Password $pfxpass