[CmdletBinding()] param( [string]$Filter = '*', [switch]$ProblemsOnly, [string]$OutputPath, [switch]$Json ) $ErrorActionPreference = 'Stop' $key = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' $properties = Get-ItemProperty -LiteralPath $key $fontsRoot = Join-Path -Path $env:SystemRoot -ChildPath 'Fonts' $rows = foreach ($property in $properties.PSObject.Properties) { if ($property.Name -like 'PS*') { continue } if ($property.Name -eq '(Default)') { continue } if ($property.Name -notlike $Filter) { continue } $file = [string]$property.Value $fullPath = Join-Path -Path $fontsRoot -ChildPath $file $exists = Test-Path -LiteralPath $fullPath -PathType Leaf $sizeKb = $null if ($exists) { $sizeKb = [math]::Round((Get-Item -LiteralPath $fullPath).Length / 1KB, 1) } [pscustomobject]@{ Font = $property.Name File = $file SizeKB = $sizeKb Exists = $exists } } if ($ProblemsOnly) { $rows = $rows | Where-Object { -not $_.Exists -or $_.SizeKB -eq 0 } } $rows = $rows | Sort-Object Exists, Font $problems = @($rows | Where-Object { -not $_.Exists -or $_.SizeKB -eq 0 }) Write-Host "Шрифтов в отчёте: $(@($rows).Count), проблемных: $($problems.Count)" if ($Json) { $text = $rows | ConvertTo-Json -Depth 4 } else { $text = $rows | Format-Table -AutoSize | Out-String -Width 220 } if ($OutputPath) { $text | Set-Content -LiteralPath $OutputPath -Encoding UTF8 Write-Host "Отчёт сохранён: $OutputPath" } else { $text }