我想安装 Balloon 驱动程序以在 KVM 中运行 Windows,无需用户任何交互(静默安装)。
我使用 powershell 将驱动程序中的证书提取到某个临时文件,然后使用 certutil.exe 将其导入到 TrustedPublisher:
$cert = (Get-AuthenticodeSignature "D:\Balloon\2k12R2\amd64\blnsvr.exe").SignerCertificate; [System.IO.File]::WriteAllBytes("c:\redhat.cer", $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert));
certutil.exe -f -addstore "TrustedPublisher" c:\redhat.cer
然后我就可以安装驱动程序,而无需通过确认打扰用户:
pnputil -i -a "d:\Balloon\2k12R2\amd64\*.inf"
如何改进此任务以在 powershell 中完成所有操作 - 无需将证书提取到临时文件并使用 certutil.exe 导入它?
最佳答案
您可以将证书数据存储在变量中,并将其直接添加到所需的存储中。例如,使用您的路径/目标:
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Cert.Import((((Get-AuthenticodeSignature "D:\Balloon\2k12R2\amd64\blnsvr.exe").SignerCertificate).Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert)))
$store = Get-Item "cert:\LocalMachine\TrustedPublisher"
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($Cert)
$store.Close()
关于powershell - 将证书从驱动程序导入到 TrustedPublisher 以进行静默驱动程序安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39266317/