什么证书用于对PS脚本进行数字签名



我关注的文章描述了如何通过创建自签名证书对PowerShell脚本进行数字签名,将其导入受信任的根证书颁发机构,然后使用对脚本进行签名

New-SelfSignedCertificate -DnsName cert_name -CertStoreLocation Cert:CurrentUserRoot -Type Codesigning
Set-AuthenticodeSignature -FilePath D:script.ps1 -Certificate (Get-ChildItem -Path Cert:CurrentUserRoot -CodeSigningCert)

这对我来说是有效的,但我想使用从AD推送的证书,并且在整个域中都是受信任的。如果使用尝试使用一个;代码签名";目的,这是从相同的命令输出:

SignerCertificate     Status       Path
-----------------     ------       ----
UnknownError script.ps1

为什么SignerCertificate字段为空,为什么脚本没有得到签名?有人能解释一下我在这里缺了什么吗?

这是一个记录良好的用例。例如:

嘿,脚本男!如何使用企业Windows PKI?第1部分和第2部分

https://devblogs.microsoft.com/scripting/hey-scripting-guy-how-can-i-sign-windows-powershell-scripts-with-an-enterprise-windows-pki-part-1-of-2

https://devblogs.microsoft.com/scripting/hey-scripting-guy-how-can-i-sign-windows-powershell-scripts-with-an-enterprise-windows-pki-part-2-of-2

$cert = Get-ChildItem -Path 'cert:currentusermy -CodeSigningCert'
Set-AuthenticodeSignature -FilePath 'D:Scripts\demoscript.ps1' -Certificate $cert -TimestampServer 'http://timestamp.comodoca.com/authenticode'

最新更新