Reputation: 725
For exemple, I have the following file:
... Thu Sep 24 15:08:21 2019 SMON: enabling cache recovery Archived Log entry 22 added for thread 1 sequence 27 ID 0xedf06523 dest 1: Thu Sep 25 13:08:45 2019 CJQ0 started with pid=33, OS id=316 Thu Sep 26 15:13:45 2019 Starting background process SMCO Thu Sep 26 15:13:45 2019 SMCO started with pid=19, OS id=2340 ...
I need to read from my current day Thu Sep 26 13:08:45 2019.
I made this, but it bring only the lines with the date.
Get-Content $alertlog | Select-String $(Get-Date -Format "ddd MMM dd")
The result:
Thu Sep 26 15:13:45 2019 Thu Sep 26 15:13:45 2019
What I need:
Thu Sep 26 15:13:45 2019 Starting background process SMCO Thu Sep 26 15:13:45 2019 SMCO started with pid=19, OS id=2340 ...
Upvotes: 0
Views: 53
Reputation: 46
Just add the -Context Parameter
Get-Content $alertlog|select-string $(Get-Date -format "ddd MMM dd") -Context 0,1
Upvotes: 3