harasho/certs/install.ps1

19 lines
616 B
PowerShell
Raw Normal View History

2023-06-02 04:07:53 +00:00
$certPath = "C:\Path\to\Certificates" # Specify the path where your .crt certificates are located
$certFiles = Get-ChildItem -Path $certPath -Filter *.crt
$certStore = Get-Item -Path "Cert:\LocalMachine\Root"
foreach ($certFile in $certFiles) {
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($certFile.FullName)
if (!$certStore.Contains($cert)) {
$certStore.Add($cert)
Write-Host "Certificate $($cert.Subject) imported successfully."
} else {
Write-Host "Certificate $($cert.Subject) already exists in the store."
}
}