Add certificate to sign files

This commit is contained in:
Gerrit 2023-07-12 17:38:55 +02:00
parent 8916b0c348
commit 747b509a0c
6 changed files with 49 additions and 4 deletions

26
sign_files.ps1 Normal file
View file

@ -0,0 +1,26 @@
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String]
$path,
[Parameter(Mandatory=$true)]
[String]
$certPath,
[Parameter(Mandatory=$true)]
[String]
$certPwd
)
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath, $certPwd)
$files = Get-ChildItem -Path $path |
Where-Object { $_.Extension -in '.dll', '.exe' } |
Select-Object -ExpandProperty FullName |
Get-AuthenticodeSignature |
Where-Object { $_.Status -eq "NotSigned" } |
Select-Object -ExpandProperty Path
foreach($file in $files){
Write-Host "Signing... $file"
Set-AuthenticodeSignature $file -Certificate $cert -TimestampServer "http://timestamp.digicert.com"
}