powershellcertificatecertutil

Import pfx file into particular certificate store from command line


It's relatively easy to import a certificate into the user's personal store from a pfx file by using CertUtil:

certutil –f –p [certificate_password] –importpfx C:\[certificate_path_and_name].pfx 

But this ends up in the Personal Store of the current user. I need it in TrustedPeople on LocalMachine.

Is there any way I can do this from the command line, either by calling different arguments on certutil importpfx, using another certutil command or a different utility? Powershell is another possibility, although I don't know much about it.

Cheers, Matt


Solution

  • Anchoring my findings here for future readers.

    Import certificate to Trusted Root Certification Authorities on Local Machine:

    CERTUTIL -addstore -enterprise -f -v root "somCertificat.cer"
    

    Import pfx to Personal on local machine

    CERTUTIL -f -p somePassword -importpfx "somePfx.pfx"
    

    Import pfx to Trusted People on local machine - Link to importpfx.exe

    importpfx.exe -f "somePfx.pfx" -p "somePassword" -t MACHINE -s "TRUSTEDPEOPLE"
    

    Import certificate to Trusted People on local machine

    Certutil -addstore -f "TRUSTEDPEOPLE" "someCertificate.cer"