Import-Certificate
Import-Certificate
Imports one or more certificates into a certificate store.
Syntax
Parameter Set: Default
Import-Certificate [-FilePath] <String> [-CertStoreLocation <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Import-Certificate cmdlet imports one or more certificates into a certificate store.
Parameters
-CertStoreLocation<String>
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.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
. |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-FilePath<String>
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.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Confirm
Prompts you for confirmation before running the cmdlet.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
System.String
A String containing the file path.
Outputs
The output type is the type of the objects that the cmdlet emits.
System.Security.Cryptography.X509Certificates.X509Certificate2[]
The output is an array of X509Certificate2[] objects.
Examples
EXAMPLE 1
This example imports the certificate from the file into the root store of the current user.
PS C:\> $file = ( Get-ChildItem -Path C:\files\root.cer )
PS C:\> $file | Import-Certificate -CertStoreLocation cert:\CurrentUser\Root
EXAMPLE 2
This example imports the certificate from the file into the current store.
PS C:\> Set-Location -Path cert:\CurrentUser\My
PS C:\> Import-Certificate -Filepath "C:\files\intermediate.cert"