# Gather information from LOG file

**URL:** <https://forums.powershell.org/t/gather-information-from-log-file/6746>\
**Category:** PowerShell Help\
**Created:** [July 4, 2016, 4:28am UTC](https://forums.powershell.org/t/gather-information-from-log-file/6746 "2016-07-04T04:28:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkata-kalyan](https://avatars.discourse-cdn.com/v4/letter/v/b3f665/32.png) [@venkata-kalyan](https://forums.powershell.org/u/venkata-kalyan)\
**Post date:** [July 4, 2016, 4:28am UTC](https://forums.powershell.org/t/gather-information-from-log-file/6746/1 "2016-07-04T04:28:45Z")

</div>

Hi,

I have a log file, which contains the below information:

ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ##################### Aggregation Status #########################  
ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ####### Aggregation Start Time - 2016-07-03 22.30.00  
ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ####### Aggregation End Time - 2016-07-03 23.30.57  
ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ####### Total Duration took to drop index - 876  
ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ####### Total Duration took to recreate index - 17468  
ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ####### Total Number of tables aggregated - 292  
ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ####### Time taken for whole process - 3657330  
ERROR 2016-07-03 23:30:57,338 schedulerFactory\_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus - ##################################################################

I need to get only Aggregation Start Time - 2016-07-03 22.30.00, Aggregation End Time - 2016-07-03 23.30.57, Time taken for whole process - 3657330 to a text file.

-Kalyan

---

<div class="post-metadata">

**Author:** ![random-commandline](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@random-commandline](https://forums.powershell.org/u/random-commandline)\
**Post date:** [July 4, 2016, 9:59am UTC](https://forums.powershell.org/t/gather-information-from-log-file/6746/2 "2016-07-04T09:59:15Z")

</div>

```
$log = Get-ChildItem \\path\to\logfile
$results = switch -Regex -File $log {
    'Aggregation (Start|End) .*' {$Matches[0]}
    'Time taken .*' {$Matches[0]}
}

$results | Out-File \\path\to\logresults.txt
```

---

<div class="post-metadata">

**Author:** ![venkata-kalyan](https://avatars.discourse-cdn.com/v4/letter/v/b3f665/32.png) [@venkata-kalyan](https://forums.powershell.org/u/venkata-kalyan)\
**Post date:** [July 5, 2016, 10:25pm UTC](https://forums.powershell.org/t/gather-information-from-log-file/6746/3 "2016-07-05T22:25:52Z")

</div>

Thanks.

-Kalyan

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:40pm UTC](https://forums.powershell.org/t/gather-information-from-log-file/6746/4 "2024-05-16T20:40:58Z")

</div>


