I am signing some built exe files with the Microsoft signtool. The command line is quite long, and always the same, apart from the target file name at the end. So I'd like to keep most of it in a handy variable:
& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\signtool.exe" sign /fd SHA256 /a /t http://timestamp.comodoca.com/authenticode $builtFile
I could store the path to signtool in a simple variable, but I want to include the arguments. How can I do that without getting a parser error?
$signTool = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\signtool.exe" sign /fd SHA256
ParserError: Unexpected token 'sign' in expression or statement.
Usually the pattern is to store the binary in one variable and the arguments in another, then you can use the call operator & as you're doing:
$signTool = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\signtool.exe"
$arguments = 'sign', '/fd', 'SHA256'
& $signTool @arguments /a /t http://...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With