Skip to content

Instantly share code, notes, and snippets.

@taddev
Created October 27, 2012 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taddev/3962920 to your computer and use it in GitHub Desktop.
Save taddev/3962920 to your computer and use it in GitHub Desktop.
A simple way to sign code in PowerShell
#
# Author: Tad DeVries
# Email: taddevries@gmail.com
# FileName: AddCert.ps1
#
# Description: Allow a simple method to sign code.
#
# Copyright (C) 2010 Tad DeVries
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# License Info: http://www.gnu.org/licenses/gpl-2.0.html
#
param([string] $FilePath=$(throw "Please specify a filename."))
$cert = @(Get-ChildItem cert:\CurrentUser\My -codesigning)[0]
Set-AuthenticodeSignature -FilePath $FilePath -Certificate $cert -TimestampServer "http://timestamp.verisign.com/scripts/timestamp.dll"
# SIG # Begin signature block
# MIIbaQYJKoZIhvcNAQcCoIIbWjCCG1YCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU5wdFVsEGltBbIQBwcZWrN8YU
# ekygghYbMIIDnzCCAoegAwIBAgIQeaKlhfnRFUIT2bg+9raN7TANBgkqhkiG9w0B
# AQUFADBTMQswCQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xKzAp
# BgNVBAMTIlZlcmlTaWduIFRpbWUgU3RhbXBpbmcgU2Vyd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rIT0Mz+FGAwBPS+Z6Jn591su07Ns5fhyKV
# uw4Q8Dt3OZdP4zmnAjeUFjJrWWVO9VOB9p1CDhrhOcDwUYr2T8o00s98uAXxCh7y
# th8UAhCMRgsoHG6GjnoHdfmnxlzoD+emryh7Yh1ra6STGHsBKFauSBtdFMMJoaVp
# vlJTxRbgN3HlPCf9xuUNmOQttZ2IytmtYwXFUwV0J+N0oaSQi2C9NwrEvxZr9M0h
# cmZmB31NL6Hje6GCAX8wggF7BgkqhkiG9w0BCQYxggFsMIIBaAIBATBnMFMxCzAJ
# BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjErMCkGA1UEAxMiVmVy
# aVNpZ24gVGltZSBTdGFtcGluZyBTZXJ2aWNlcyBDQQIQeaKlhfnRFUIT2bg+9raN
# 7TAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG
# 9w0BCQUxDxcNMTIxMDI3MDI0NDQ2WjAjBgkqhkiG9w0BCQQxFgQU4g+MwBaLaaIA
# UY+15zrmJivl9qAwDQYJKoZIhvcNAQEBBQAEgYAh0k/aCyXSVffJwIU1tOtg3VVH
# LCUeXFNM6Tdkon8XosjSRaWyraH1gzmtzslzm7Ou7iPYW/x124mPJs58IF8pGsTo
# uDErTYJXt8zoFb8nVcAIoKkmgRs2wuzOpTGqEvj3/w+ewXX8tmZ8V/OspaNqisFN
# K36sGR1D3xaSpDf6VQ==
# SIG # End signature block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment