It has been many years ago I needed to automate and use certutil.exe program to import a certificate. In the past I used SCCM program to run a certain script to import a certificate for me.
Recently while working on a project to setup ADFS and WAP servers I needed to export and import so many times a certificate (with private key) that automating this process was key to make sure all servers and services were aligned with the same certificate.
To do that I used powershell to help and use remote powershell on my servers to speed up the process.
How to export a certificate with powershell?
Enter-PSSession -ComputerName ADFS-01 $thumprint = (Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Subject -match "CN=ssl.networknet.nl"}).Thumbprint $pwd = ConvertTo-SecureString -String "password" -Force -AsPlainText Get-ChildItem -Path Cert:\LocalMachine\My\$thumprint | Export-PfxCertificate -FilePath C:\ssl.networknet.nl.pfx -Password $pwd
How to import a certificate with powershell?
Enter-PSSession -ComputerName ADFS-02 $pwd = ConvertTo-SecureString -String "password" -Force -AsPlainText Import-PfxCertificate -FilePath C:\adfs.networknet.nl.pfx Cert:\LocalMachine\My -Password $pwd
My current script does not copy the PFX file that gets exported locally and it needs to be copied to the remote servers C:\ volume. This step could also be automated with powershell.
barcatoto
thank you verry much all