← Share another text

Shared on Droptext

Untitled text

Posted on 2026-11-1021 views
$ErrorActionPreference = "SilentlyContinue" $results = [System.Collections.Generic.List[object]]::new() $drives = Get-CimInstance Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } | Select-Object -ExpandProperty DeviceID foreach ($drive in $drives) { Write-Host "Проверяю диск $drive ..." -ForegroundColor Cyan $files = Get-ChildItem "$drive\" -Filter *.xlsx -Recurse -File -Force -ErrorAction SilentlyContinue foreach ($file in $files) { try { $package = Open-ExcelPackage -Path $file.FullName foreach ($sheet in $package.Workbook.Worksheets) { if ($null -eq $sheet.Dimension) { continue } for ($r = $sheet.Dimension.Start.Row; $r -le $sheet.Dimension.End.Row; $r++) { for ($c = $sheet.Dimension.Start.Column; $c -le $sheet.Dimension.End.Column; $c++) { $cell = $sheet.Cells[$r, $c] $value = $cell.Value $matchDate = $false if ($value -is [datetime]) { $matchDate = ($value.Date -eq [datetime]'2026-11-10') } elseif ($null -ne $value) { $matchDate = ("$value" -match '(?<!\d)10[./-]11[./-]2026(?!\d)') if (-not $matchDate -and $value -is [double]) { try { $matchDate = ([datetime]::FromOADate($value).Date -eq [datetime]'2026-11-10') } catch {} } } if ($matchDate) { $results.Add([PSCustomObject]@{ File = $file.FullName Sheet = $sheet.Name Cell = $cell.Address Value = "$value" }) } } } } Close-ExcelPackage $package } catch { Write-Host "Ошибка чтения: $($file.FullName)" -ForegroundColor Yellow } } } $results | Format-Table -AutoSize -Wrap $results | Export-Csv "$env:USERPROFILE\Desktop\Found_Excel_Dates.csv" -NoTypeInformation -Encoding UTF8 Write-Host "ПОИСК ЗАВЕРШЁН. Найдено: $($results.Count)" -ForegroundColor Green Write-Host "Отчёт сохранён на Рабочем столе: Found_Excel_Dates.csv"