Import-Certificate
Imports one or more certificates into a certificate store.
Syntax
Default (Default)
Import-Certificate
[-FilePath] <String>
[-CertStoreLocation <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Import-Certificate
cmdlet imports one or more certificates into a certificate store.
Examples
EXAMPLE 1
$params = @{
FilePath = 'C:\Users\Xyz\Desktop\BackupCert.cer'
CertStoreLocation = 'Cert:\CurrentUser\Root'
}
Import-Certificate @params
This example imports the certificate from the file into the root store of the current user.
EXAMPLE 2
Set-Location -Path cert:\CurrentUser\My
Import-Certificate -Filepath 'C:\files\intermediate.cert'
This example imports the certificate from the file into the current store.
EXAMPLE 3
$params = @{
FilePath = 'C:\Users\Xyz\Desktop\BackupCert.cer'
CertStoreLocation = 'Cert:\LocalMachine\Root'
}
Import-Certificate @params
This example imports the certificate from the file into the root store of the local machine.
Parameters
-CertStoreLocation
Specifies the path to the certificate store where the certificates will be imported. If the path to
the certificate store is not specified, then the current store is used. In order to get a list of
valid CertStoreLocation values, open PowerShell and run Get-ChildItem Cert:\
.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | cf |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-FilePath
Specifies the path to a certificate file to be imported. Acceptable formats include .sst
, .p7b
,
and .cert
files. If the file contains multiple certificates, then each certificate will be
imported to the destination store. The file must be in .sst
format to import multiple
certificates; otherwise, only the first certificate in the file will be imported.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | FullName |
Parameter sets
(All)
Position: | 0 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | wi |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
String
A String containing the file path.
Outputs
X509Certificate2
The output is an array of X509Certificate2[] objects.