-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignfiles.ps1
31 lines (23 loc) · 1.19 KB
/
signfiles.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
param(
[string]
[Parameter(Mandatory=$true)]
# Folder path that contains the files you would like to sign. Recursive.
$PathToSignableFiles,
[string]
# The code signing certificate to use when signing the files.
$CertificatePath = "C:\mRemoteNG_code_signing_cert.pfx",
[SecureString]
# Password to unlock the code signing certificate.
$CertificatePassword = (Get-Credential -Message "Enter password for the mRemoteNG code signing certificate" -UserName "USERNAME NOT NEEDED").Password,
[string[]]
# File names to exclude from signing
$Exclude
)
$timeserver = "http://timestamp.verisign.com/scripts/timstamp.dll"
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($CertificatePath, $CertificatePassword)
Write-Output "Getting files from path: $PathToSignableFiles"
$signableFiles = Get-ChildItem -Path $PathToSignableFiles -Recurse | ?{$_.Extension -match "dll|exe|msi"} | ?{$Exclude -notcontains $_.Name}
Write-Output "Signable files count: $($signableFiles.Count)"
foreach ($file in $signableFiles) {
Set-AuthenticodeSignature -Certificate $cert -TimestampServer $timeserver -IncludeChain all -FilePath $file.FullName
}