Len Kally
asked on
PowerShell command for PFX certificate with password not working, help!
I am trying to install a certificate via powershell, and it keeps telling store does not exist. Can someone advise what I am doing wrong.
I have a xxx.pfx certificate with a password and I want to install it to the Trusted Publishers store on the local computer.
The certificate is for the machine
Import-PfxCertificate -FilePath c:\swsetup\xxxx20220426.pf x -StoreLocation LocalMachine -StoreName TrustedPublishers -Exportable -Password xyzxyz
Can someone help me with the correct PowerShell command.
I have a xxx.pfx certificate with a password and I want to install it to the Trusted Publishers store on the local computer.
The certificate is for the machine
Import-PfxCertificate -FilePath c:\swsetup\xxxx20220426.pf
Can someone help me with the correct PowerShell command.
ASKER
This works fine, but now how do I do this without asking for a password.
Not worried about security right now, what is the command I need that I can specify a password.
Thanks
Not worried about security right now, what is the command I need that I can specify a password.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks how can I insert a password without having to show it.
The above "mypassword" would be seen in the script.
How can I run the script without showing the password.
The above "mypassword" would be seen in the script.
How can I run the script without showing the password.
You said you weren't concerned about security. I've already given you two options, one that's secure and one that's not, so I'm not really sure what you're after.
You could put the password in a separate file and then read that in.
$pass = ConvertTo-SecureString (Get-Content "c:\temp\passwordfile.txt" ) -AsPlainText -Force
If you really are concerned with security after all, but don't want a prompt, then you can put the password in a file in an encrypted form. I'll direct you to the help for the ConvertTo-SecureString parameter for more details -
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/convertto-securestring?view=powershell-5.1
Note that using this method, you will either have to either provide the value to the -Key parameter, or decryption of the file contents can only be done by using the same account on the same machine where the file contents were created. For more questions on this I'll ask that you create a new question as it is a far different question than your original one of how to import a certificate.
You could put the password in a separate file and then read that in.
$pass = ConvertTo-SecureString (Get-Content "c:\temp\passwordfile.txt"
If you really are concerned with security after all, but don't want a prompt, then you can put the password in a file in an encrypted form. I'll direct you to the help for the ConvertTo-SecureString parameter for more details -
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/convertto-securestring?view=powershell-5.1
Note that using this method, you will either have to either provide the value to the -Key parameter, or decryption of the file contents can only be done by using the same account on the same machine where the file contents were created. For more questions on this I'll ask that you create a new question as it is a far different question than your original one of how to import a certificate.
Open in new window