← Share another text

Shared on Droptext

Untitled text

Posted on 2026-11-1019 views
Add-Type -AssemblyName System.IO.Compression.FileSystem $found = @() $target = [datetime]'2026-11-10' Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | ForEach-Object { $drive = $_.DeviceID Write-Host "Сканирую $drive ..." -ForegroundColor Cyan Get-ChildItem "$drive\" -Filter *.xlsx -File -Recurse -ErrorAction SilentlyContinue | ForEach-Object { $f = $_ try { $z = [IO.Compression.ZipFile]::OpenRead($f.FullName) try { $ss = @() $e = $z.GetEntry('xl/sharedStrings.xml') if ($e) { $r = [IO.StreamReader]::new($e.Open()) [xml]$sx = $r.ReadToEnd() $r.Close() $ss = @($sx.SelectNodes("//*[local-name()='si']") | ForEach-Object { ($_.SelectNodes(".//*[local-name()='t']") | ForEach-Object {$_.InnerText}) -join '' }) } foreach ($e in $z.Entries | Where-Object {$_.FullName -match '^xl/worksheets/sheet\d+\.xml$'}) { $r = [IO.StreamReader]::new($e.Open()) [xml]$sx = $r.ReadToEnd() $r.Close() foreach ($c in $sx.SelectNodes("//*[local-name()='c']")) { $v = $c.SelectSingleNode("./*[local-name()='v']") if (!$v) {continue} $val = $v.InnerText $type = $c.GetAttribute('t') if ($type -eq 's') { $val = $ss[[int]$val] } $ok = "$val" -match '(?<!\d)10[./-]11[./-]2026(?!\d)' if (!$ok -and $type -ne 's' -and $val -match '^\d+(\.\d+)?$') { $styles = $z.GetEntry('xl/styles.xml') if ($styles) { # Проверка числового значения даты будет выполнена ниже $num = [double]$val $ok = ($num -ge 46335 -and $num -lt 46336) } } if ($ok) { $found += [PSCustomObject]@{ File = $f.FullName Sheet = $e.FullName Cell = $c.GetAttribute('r') Value = $val } Write-Host "НАЙДЕНО: $($f.FullName) | $($c.GetAttribute('r')) | $val" -ForegroundColor Green } } } } finally {$z.Dispose()} } catch { Write-Host "Ошибка чтения: $($f.FullName) : $($_.Exception.Message)" -ForegroundColor Yellow } } } $found | Export-Csv "$env:USERPROFILE\Desktop\Found_Dates.csv" -NoTypeInformation -Encoding UTF8 Write-Host "ГОТОВО. Найдено: $($found.Count). Отчёт на Рабочем столе." -ForegroundColor Green