Is there any way to check for digital signature on a file programmatically in Powershell?

I've a build script which signs a file with a digital certificate (Microsoft Authenticode). I want to create a test script which checks that the file is successfully signed. It's sufficient with a boolean indicating the existence of any signature on the file.

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

3 Answers

Try the Get-AuthenticodeSignature-cmdlet

(Get-AuthenticodeSignature "C:\windows\explorer.exe").Status -eq 'Valid'
True
(Get-AuthenticodeSignature "D:\notes.txt").Status -eq 'Valid'
False
0

You could simply call signtool.exe to verify the result.

2

Also you can use sign-check util (npm required).

Install: npm install -g sign-check

Usage: sign-check 'path/to/file'

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like