Files
powershell/Dennis_Scripts/AddCPRCertificatesToStore.ps1
2023-03-09 09:06:25 +01:00

78 lines
4.3 KiB
PowerShell

&{
# AddTrustExternalCARoot
if(-not (Get-Item cert:\LocalMachine\Root\02FAF3E291435468607857694DF5E45B68851868 -ErrorAction SilentlyContinue)) {
# Open certificate store
$CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "\\.\Root", "LocalMachine"
$CertStore.Open('ReadWrite')
# Read certificate file
$Certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Certificate.Import('D:\Certificates\CPR14042015\AddTrustExternalCARoot.crt')
# Add certificate to store
$CertStore.Add($Certificate)
$CertStore.Close()
Write-Host -ForegroundColor Yellow "AddTrustExternalCARoot installed"
}
else {
Write-Host -ForegroundColor Yellow "AddTrustExternalCARoot not installed"
}
# COMODORSACertificationAuthority
if(-not (Get-Item cert:\LocalMachine\CA\F5AD0BCC1AD56CD150725B1C866C30AD92EF21B0 -ErrorAction SilentlyContinue)) {
$CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "\\.\CA", "LocalMachine"
$CertStore.Open('ReadWrite')
$Certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Certificate.Import('D:\Certificates\CPR14042015\COMODORSACertificationAuthority.crt')
$CertStore.Add($Certificate)
$CertStore.Close()
Write-Host -ForegroundColor Yellow "COMODORSACertificationAuthority installed"
}
else {
Write-Host -ForegroundColor Yellow "COMODORSACertificationAuthority not installed"
}
# COMODORSADomainValidationSecureServerCA
if(-not (Get-Item cert:\LocalMachine\CA\339CDD57CFD5B141169B615FF31428782D1DA639 -ErrorAction SilentlyContinue)) {
$CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "\\.\CA", "LocalMachine"
$CertStore.Open('ReadWrite')
$Certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Certificate.Import('D:\Certificates\CPR14042015\COMODORSADomainValidationSecureServerCA.crt')
$CertStore.Add($Certificate)
$CertStore.Close()
Write-Host -ForegroundColor Yellow "COMODORSADomainValidationSecureServerCA installed"
}
else {
Write-Host -ForegroundColor Yellow "COMODORSADomainValidationSecureServerCA not installed"
}
# -.cpr.dk
if(-not (Get-Item cert:\LocalMachine\My\F6C78C9BD32ADEC12BF5FC3A67ACEB3C684FF8C1 -ErrorAction SilentlyContinue)) {
$CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "\\.\My", "LocalMachine"
$CertStore.Open('ReadWrite')
$Certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Certificate.Import('D:\Certificates\CPR14042015\-.cpr.dk.crt')
$CertStore.Add($Certificate)
$CertStore.Close()
Write-Host -ForegroundColor Yellow "-.cpr.dk installed"
}
else {
Write-Host -ForegroundColor Yellow "-.cpr.dk not installed"
}
if(Get-Item cert:\LocalMachine\Root\02FAF3E291435468607857694DF5E45B68851868 -ErrorAction SilentlyContinue) { Write-Host -ForegroundColor Green "AddTrustExternalCARoot found" } else { Write-Host -ForegroundColor Red "AddTrustExternalCARoot not found" }
if(Get-Item cert:\LocalMachine\CA\F5AD0BCC1AD56CD150725B1C866C30AD92EF21B0 -ErrorAction SilentlyContinue) { Write-Host -ForegroundColor Green "COMODORSACertificationAuthority found" } else { Write-Host -ForegroundColor Red "COMODORSACertificationAuthority not found" }
if(Get-Item cert:\LocalMachine\CA\339CDD57CFD5B141169B615FF31428782D1DA639 -ErrorAction SilentlyContinue) { Write-Host -ForegroundColor Green "COMODORSADomainValidationSecureServerCA found" } else { Write-Host -ForegroundColor Red "COMODORSADomainValidationSecureServerCA not found" }
if(Get-Item cert:\LocalMachine\My\F6C78C9BD32ADEC12BF5FC3A67ACEB3C684FF8C1 -ErrorAction SilentlyContinue) { Write-Host -ForegroundColor Green "-.cpr.dk found" } else { Write-Host -ForegroundColor Red "-.cpr.dk not found" }
}