how to check if a file has a digital signature

前端 未结 7 1250
情书的邮戳
情书的邮戳 2020-12-05 17:07

I\'d like to check programatically if a file has been digitally signed or not.

For the moment, I found a rather obscure code in MSDN, that doesn\'t compile...

<
7条回答
  •  渐次进展
    2020-12-05 17:48

    Since Powershell 5.1, you can use Get-AuthenticodeSignature to verifiy the signature of a Binary or a PowerShell Script.

    > Get-AuthenticodeSignature -FilePath .\MyFile.exe
    
    SignerCertificate                 Status        Path                                                                                   
    -----------------                 ------        ----                                                                                   
    A59E92E31475F813DDAF41C3CCBC8B78  Valid         MyFile.exe   
    

    Or

    > (Get-AuthenticodeSignature -FilePath .\MyFile.exe).Status
    Valid
    

提交回复
热议问题