Import-Certificate
Imports one or more certificates into a certificate store.
Syntax
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
PS C:\>$file = ( Get-ChildItem -Path C:\files\root.cer )
PS C:\>$file | Import-Certificate -CertStoreLocation cert:\CurrentUser\Root
This example imports the certificate from the file into the root store of the current user.
EXAMPLE 2
PS C:\>Set-Location -Path cert:\CurrentUser\My
PS C:\>Import-Certificate -Filepath "C:\files\intermediate.cert"
This example imports the certificate from the file into the current store.
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.
Type: | String |
Position: | Named |
Default value: | . |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | String |
Aliases: | FullName |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
A String containing the file path.
Outputs
The output is an array of X509Certificate2[] objects.
Related Links
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for