2017-01-20 41 views
0

我有证书的certmgr和我能够把它也使用:PowerShell的分配证书

$a=Get-ChildItem –Path cert:\CurrentUser\my –codeSigningCert 

现在我该怎么分配相同的代码签名证书,使我的所有脚本进行数字签名? 有没有直接的方法来实现它?

+0

http://stackoverflow.com/questions/41646811/powershell-to-run-task-sequence-from-software-center#comment70560786_41646811 :) –

+0

@PrageethSaravanan:问题已通过直接从外部获取数字签名的脚本解决。我们不必分配它。虽然Set-AuthenticodeSignature将完成这项工作。 –

回答

0

可以使用Set-AuthenticodeSignature的cmdlet:

$Cert = Get-PfxCertificate -FilePath "C:\Test\Mysign.pfx" 
Set-AuthenticodeSignature -FilePath "ServerProps.ps1" -Certificate $Cert 

Set-AuthenticodeSignature c:\foo.ps1 @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] 

,如果你想了解更多信息,请参阅the MS linkthis link