-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSet-Signature.ps1
More file actions
25 lines (22 loc) · 880 Bytes
/
Set-Signature.ps1
File metadata and controls
25 lines (22 loc) · 880 Bytes
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
function Set-Signature {
param(
[Parameter(Position=0, Mandatory=$TRUE, ValueFromPipeline=$TRUE)]
[IO.FileInfo] $file,
[Parameter(Position=1, Mandatory=$FALSE, ValueFromPipeline=$FALSE)]
[System.Security.Cryptography.X509Certificates.X509Certificate] $Certificate
);
begin {
if(-not $Certificate) {
$Certificate = (dir cert:currentuser\my\ -CodeSigningCert | ? { $_.Extensions } | Select-Object -First 1)
}
if(-not ($Certificate) ) {
Write-Warning 'Could not find certificate for signing'
return
}
}
process {
if($Certificate) {
Set-AuthenticodeSignature $file -Certificate $Certificate -IncludeChain all -TimestampServer http://timestamp.verisign.com/scripts/timstamp.dll
}
}
}