Skip to content

Commit 8efb0fa

Browse files
committed
Adding support for filtering of OS binaries, as well as defaulting to '-All'
1 parent cb91cdb commit 8efb0fa

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

AutoRuns.psm1

+33-20
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,11 @@ Begin {
460460

461461
)
462462
Begin {
463+
## Add 'All' if nothing else was supplied
464+
if(($PSBoundParameters.Keys | ? { $_ -notin "ShowFileHash","VerifyDigitalSignature" }).Count -eq 0)
465+
{
466+
$All = [switch]::Present
467+
}
463468
}
464469
Process {
465470
if ($All -or $BootExecute) {
@@ -2160,30 +2165,38 @@ Begin {
21602165
If ($VerifyDigitalSignature) {
21612166
if ($_.ImagePath) {
21622167
If (Test-Path -Path $_.ImagePath -PathType Leaf) {
2163-
$_ | Add-Member -MemberType ScriptProperty -Name Signed -Value ({
2164-
try {
2165-
$signature = Get-AuthenticodeSignature -FilePath $($this.ImagePath) -ErrorAction Stop
2166-
Switch ($signature.Status) {
2167-
'Valid' {
2168-
$true
2169-
break
2170-
}
2171-
'NotSigned' {
2172-
$false
2173-
break
2174-
}
2175-
default {
2176-
$false
2177-
}
2178-
}
2179-
2180-
} catch {
2168+
2169+
## Add the signature status to the entry
2170+
$signature = Get-AuthenticodeSignature -FilePath $_.ImagePath -ErrorAction Stop
2171+
$signed = switch ($signature.Status) {
2172+
'Valid' {
2173+
$true
2174+
break
2175+
}
2176+
'NotSigned' {
2177+
$false
2178+
break
2179+
}
2180+
default {
21812181
$false
21822182
}
2183-
}) -Force -PassThru
2183+
}
2184+
$_ = $_ | Add-Member -MemberType NoteProperty -Name Signed -Value $signed -Force -PassThru
2185+
2186+
## Add a note whether this is an OS binary to allow for easy filtering:
2187+
## Get-PSAutorun -VerifyDigitalSignature | ? { -not $_.IsOSBinary }
2188+
if($signature.IsOSBinary)
2189+
{
2190+
$_ = $_ | Add-Member -MemberType NoteProperty -Name IsOSBInary -Value $signature.IsOSBinary -Force -PassThru
2191+
}
2192+
2193+
## Add the signer itself
2194+
$_ | Add-Member -MemberType NoteProperty -Name Publisher -Value $signature.SignerCertificate.Subject -Force -PassThru
21842195
}
21852196
} else {
2186-
$_ | Add-Member -MemberType NoteProperty -Name Signed -Value $null -Force -PassThru
2197+
$_ = $_ | Add-Member -MemberType NoteProperty -Name Signed -Value $null -Force -PassThru
2198+
$_ = $_ | Add-Member -MemberType NoteProperty -Name IsOSBinary -Value $null -Force -PassThru
2199+
$_ | Add-Member -MemberType NoteProperty -Name Publisher -Value $null -Force -PassThru
21872200
}
21882201
} else {
21892202
$_

0 commit comments

Comments
 (0)