[CmdletBinding()] param( [string[]]$Path, [string]$OutputPath, [switch]$Json ) $ErrorActionPreference = 'Stop' $defaults = @( "$env:SystemRoot\System32\winlogon.exe", "$env:SystemRoot\System32\lsass.exe", "$env:SystemRoot\System32\services.exe", "$env:SystemRoot\System32\svchost.exe", "$env:SystemRoot\System32\kernel32.dll", "$env:SystemRoot\System32\ntoskrnl.exe", "$env:SystemRoot\System32\user32.dll", "$env:SystemRoot\System32\advapi32.dll" ) if (-not $Path) { $Path = $defaults } $rows = foreach ($file in $Path) { if (-not (Test-Path -LiteralPath $file -PathType Leaf)) { [pscustomobject]@{ File = $file Status = 'NotFound' Signer = '' Message = 'Файл не найден' } continue } try { $signature = Get-AuthenticodeSignature -LiteralPath $file -ErrorAction Stop [pscustomobject]@{ File = $file Status = [string]$signature.Status Signer = [string]$signature.SignerCertificate.Subject Message = [string]$signature.StatusMessage } } catch { [pscustomobject]@{ File = $file Status = 'Error' Signer = '' Message = $_.Exception.Message } } } $bad = @($rows | Where-Object { $_.Status -ne 'Valid' }) Write-Host "Проверено файлов: $(@($rows).Count), не прошли проверку: $($bad.Count)" if ($Json) { $text = $rows | ConvertTo-Json -Depth 4 } else { $text = $rows | Format-Table -Wrap | Out-String -Width 260 } if ($OutputPath) { $text | Set-Content -LiteralPath $OutputPath -Encoding UTF8 Write-Host "Отчёт сохранён: $OutputPath" } else { $text }