Skip to content
PowerShell Commands

Import-PfxCertificate

Import-PfxCertificate [-FilePath*] <String> [[-CertStoreLocation] <String>] [-Exportable] [-Password<SecureString>] [-Confirm] [-WhatIf] [<CommonParameters>]

The Import-PfxCertificate cmdlet imports certificates and private keys from a PFX file to the destination store. Certificates with and without private keys in the PFX file are imported, along with any external properties that are present.

Delegation may be required when using this cmdlet with Windows PowerShellr remoting and changing user configuration.

Parameters

-CertStoreLocation [<String>]

Specifies the path of the store to which certificates will be imported. If this parameter is not specified, then the current path is used as the destination store.

-Exportable [<SwitchParameter>]

Specifies whether the imported private key can be exported. If this parameter is not specified, then the private key cannot be exported.

-FilePath <String>

  • This value is required
  • Accepts pipeline input ByPropertyName

Specifies the path for the PFX file.

-Password [<SecureString>]

Specifies the password for the imported PFX file in the form of a secure string.

-Confirm [<SwitchParameter>]

  • Default value is false

Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.

-WhatIf [<SwitchParameter>]

  • Default value is false

Shows what would happen if the cmdlet runs. The cmdlet is not run.Shows what would happen if the cmdlet runs. The cmdlet is not run.

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.

Inputs
System.String
A String containing the path to the PFX file.
Outputs
System.Security.Cryptography.X509Certificates.X509Certificate2
The imported X509Certificate2 object contained in the PFX file that is associated with private keys. EXAMPLE 1 PS C:\>$mypwd = ConvertTo-SecureString -String "1234" -Force -AsPlainText PS C:\>Import-PfxCertificate -FilePath C:\mypfx.pfx cert:\localMachine\my -Password $mypwd This example imports the PFX file my.pfx with a private non-exportable key into the My store for the machine account. EXAMPLE 2 PS C:\>Get-ChildItem -Path c:\mypfx\my.pfx | Import-PfxCertificate -CertStoreLocation Cert:\CurrentUser\My -Exportable This example imports the PFX file my.pfx with a private non-exportable key into the My store for the current user with private key exportable. The Password parameter is not required since this PFX file is not password protected. EXAMPLE 3 PS C:\>Set-Location -Path cert:\localMachine\my PS C:\>Import-PfxCertificate -FilePath c:\mypfx.pfx This example imports the PFX file mypfx.pfx into the My store for the machine account. The Password parameter is not required since this PFX file is protected using the domain account of this machine. This requires a Windows Serverr 2012 domain controller.

    This work is licensed under a Creative Commons Attribution 4.0 International. It is attributed to Microsoft Corporation and can be found here.

    PowerShell Commands