[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Path, [ValidateRange(1, 1048576)] [int]$MinSizeMB = 500, [ValidateRange(1, 500)] [int]$Top = 50, [string]$Csv ) $ErrorActionPreference = 'Stop' if (-not (Test-Path -LiteralPath $Path -PathType Container)) { throw "Каталог не найден: $Path" } $resolved = (Resolve-Path -LiteralPath $Path).ProviderPath $minBytes = [int64]$MinSizeMB * 1MB $files = @( Get-ChildItem -LiteralPath $resolved -File -Recurse -Force -ErrorAction SilentlyContinue | Where-Object { $_.Length -ge $minBytes } | Sort-Object -Property Length -Descending | Select-Object -First $Top | Select-Object @{Name = 'SizeMB'; Expression = { [math]::Round($_.Length / 1MB, 1) } }, LastWriteTime, FullName ) if ($files.Count -eq 0) { Write-Host "Файлов больше $MinSizeMB MB не найдено." return } $total = ($files | Measure-Object -Property SizeMB -Sum).Sum Write-Host ("Показано файлов: {0}, суммарный размер: {1:N1} MB" -f $files.Count, $total) $files | Format-Table -AutoSize if ($Csv) { $files | Export-Csv -LiteralPath $Csv -NoTypeInformation -Encoding UTF8 Write-Host "Отчёт сохранён: $Csv" }