Get-PfxCertificate
now has the Password
parameter, which takes a SecureString
. This allows you to use it non-interactively:PowerShellCopy
$certFile = '\\server\share\pwd-protected.pfx'
$certPass = Read-Host -AsSecureString -Prompt 'Enter the password for certificate: '
$certThumbPrint = (Get-PfxCertificate -FilePath $certFile -Password $certPass ).ThumbPrint