How to install a certificate to the certificate store using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To install the certificate using PowerShell, we need to use the Import-Certificate command. For example, we have a certificate stored at the location C:\temp\Mycert.cer and we need to install it in the Personal store of the local machine.

Example

Import-Certificate -FilePath C:\Temp\Mycert.cer `
   -CertStoreLocation Cert:\LocalMachine\My\

You can also use the below method.

PS C:\> Set-Location Cert:\LocalMachine\My\
PS Cert:\LocalMachine\My\> Import-Certificate -FilePath C:\Temp\Mycert.cer

To install a certificate on the remote computer, use the Invoke-Command method.

Syntax

Invoke-Command -ComputerName  RemoteServer1 -ScriptBlock {Import-Certificate -FilePath C:\Temp\Mycert.cer `
   -CertStoreLocation Cert:\LocalMachine\My\ }

The above command will install the certificate on RemoteServer1 from the path C:\temp of the remote server to the personal store of the remote machine.

raja
Published on 18-Mar-2021 07:31:55
Advertisements