← Share another text

Shared on Droptext

Untitled text

Posted on 2026-11-1020 views
$ErrorActionPreference = "SilentlyContinue" $excel = New-Object -ComObject Excel.Application $excel.Visible = $false $excel.DisplayAlerts = $false $files = Get-ChildItem C:\ -Filter *.xlsx -Recurse -File -ErrorAction SilentlyContinue $results = @() foreach ($file in $files) { $wb = $null try { $wb = $excel.Workbooks.Open($file.FullName, 0, $true) foreach ($sheet in $wb.Worksheets) { $used = $sheet.UsedRange $found = $used.Find( "10.11.2026", [Type]::Missing, 1, 1, 1, 1, $false ) if ($found) { $firstAddress = $found.Address() do { $results += [PSCustomObject]@{ File = $file.FullName Sheet = $sheet.Name Cell = $found.Address() Value = $found.Text } $found = $used.FindNext($found) } while ($found -and $found.Address() -ne $firstAddress) } # Проверка настоящих дат Excel foreach ($cell in $used.Cells) { if ($cell.Value2 -is [double]) { try { $date = [DateTime]::FromOADate($cell.Value2) if ($date.Date -eq [datetime]'2026-11-10') { $results += [PSCustomObject]@{ File = $file.FullName Sheet = $sheet.Name Cell = $cell.Address() Value = $cell.Text } } } catch {} } } } } catch { Write-Host "Ошибка: $($file.FullName)" } finally { if ($wb) { $wb.Close($false) [void][Runtime.InteropServices.Marshal]::ReleaseComObject($wb) } } } $excel.Quit() [void][Runtime.InteropServices.Marshal]::ReleaseComObject($excel) $results | Sort-Object File, Sheet, Cell -Unique | Format-Table -AutoSize -Wrap