有没有办法在Powershell中以编程方式检查文件上的数字签名?

Nil*_*zor 9 powershell command-line authenticode

我有一个构建脚本,用于使用数字证书(Microsoft Authenticode)对文件进行签名.我想创建一个测试脚本,检查文件是否成功签名.布尔表示文件上存在任何签名就足够了.

我可以在没有任何扩展的情况下使用PowerShell吗?如果没有,我需要什么?

Fro*_* F. 19

试试Get-AuthenticodeSignature-cmdlet

(Get-AuthenticodeSignature "C:\windows\explorer.exe").Status -eq 'Valid'

True

(Get-AuthenticodeSignature "D:\notes.txt").Status -eq 'Valid'

False
Run Code Online (Sandbox Code Playgroud)