12

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?

RBT
  • 24,161
  • 21
  • 159
  • 240
Nilzor
  • 18,082
  • 22
  • 100
  • 167

3 Answers3

22

Try the Get-AuthenticodeSignature-cmdlet

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

True

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

False
Daniel Lo Nigro
  • 3,346
  • 27
  • 29
Frode F.
  • 52,376
  • 9
  • 98
  • 114
3

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

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
0

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

Install: npm install -g sign-check

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

kami4ka
  • 187
  • 1
  • 12