Is there a way to verify the electronic signature in a file programmatically in Powershell?

I have a build script that signs a digital certificate file (Microsoft Authenticode). I want to create a test script that checks that the file is successfully signed. This is sufficient with a boolean indicating the presence of any signature in the file.

Can I do this with PowerShell without any extensions? If not, what do I need?

+4
source share
3 answers

Try Get-AuthenticodeSignature-cmdlet

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

True

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

False
+11
source

You can simply call signtool.exe to check the result.

+2
source

check-check ( npm).

: npm install -g sign-check

: sign-check 'path/to/file'

+1

All Articles