install root ca

This commit is contained in:
Aleksandr Chebotov
2020-03-31 12:22:38 +03:00
parent ff07d56975
commit 1201c933b6

View File

@@ -2,23 +2,21 @@
$sstFile = "$env:TEMP\roots.sst"
# Generate SST from Windows Update
$result = certutil.exe -generateSSTFromWU $sstFile
if ($LASTEXITCODE -eq 0) {
# Dump certificates
$result = certutil.exe -dump $sstFile
if ($LASTEXITCODE -eq 0) {
# Import Root CA into "Trusted Root Certification Authority"
try {
Import-Certificate -FilePath $sstFile -CertStoreLocation Cert:\LocalMachine\Root
} catch {
Write-Host "[Error]: failed to import ROOT CA`n$_"
}
}
else {
Write-Host "[Error]: failed to dump $sstFile sst file`n$result"
}
}
else {
if ($LASTEXITCODE -ne 0) {
Write-Host "[Error]: failed to generate $sstFile sst file`n$result"
exit $LASTEXITCODE
}
$result = certutil.exe -dump $sstFile
if ($LASTEXITCODE -ne 0) {
Write-Host "[Error]: failed to dump $sstFile sst file`n$result"
exit $LASTEXITCODE
}
try {
Import-Certificate -FilePath $sstFile -CertStoreLocation Cert:\LocalMachine\Root
} catch {
Write-Host "[Error]: failed to import ROOT CA`n$_"
exit 1
}
exit $LASTEXITCODE