Install-Certificate

Installs a certificate in a given store.

Syntax

Install-Certificate [-Path] <String> [-StoreLocation] {CurrentUser | LocalMachine} [-StoreName] {AddressBook | AuthRoot | CertificateAuthority | Disallowed | My | Root | TrustedPeople | TrustedPublisher} [-Exportable] [[-Password] <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

Uses the .NET certificates API to add a certificate to a store for the machine or current user. The user performing the action must have permission to modify the store or the installation will fail.

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String The path to the certificate file. true false
StoreLocation StoreLocation The location of the certificate's store. To see a list of acceptable values, run:
[Enum]::GetValues([Security.Cryptography.X509Certificates.StoreLocation])
true false
StoreName StoreName The name of the certificate's store. To see a list of acceptable values run:
[Enum]::GetValues([Security.Cryptography.X509Certificates.StoreName])
true false
Exportable SwitchParameter Mark the private key as exportable. false false
Password Object The password for the certificate. Can be a string or a System.Security.SecureString. false false
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.

Return Values

System.Security.Cryptography.X509Certificates.X509Certificate2. An X509Certificate2 object representing the newly installed certificate.

EXAMPLE 1

Install-Certificate -Path C:\Users\me\certificate.cer -StoreLocation LocalMachine -StoreName My -Exportable -Password My5up3r53cur3P@55w0rd

Installs the certificate (which is protected by a password) at C:\Users\me\certificate.cer into the local machine's Personal store. The certificate is marked exportable.