Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I managed to get this running more or less as I desired.</p> <p>Below the answer:</p> <p>Currently I have like 15 network paths to check for latest update.</p> <pre><code>$Path1 = "\\path-to-the-jou-file-for-2h-check\joufile.jou" $Path2 = "\\path-to-the-jou-file-for-24h-check\joufile.jou" </code></pre> <p>I defined a 2h and 24h Get-Date aliases. For my needs, I had to check $Path2 file for entries from yesterday, and $path1 to be checked for current hour, last hour and 2 hours ago.</p> <pre><code>$npath = path-to-my-output-file $date24 = (Get-Date).AddHours(-24).ToString("dd.MM.yyyy") $date2 = (Get-Date).AddHours(-2).ToString("dd.MM.yyyy HH") $date1 = (Get-Date).AddHours(-1).ToString("dd.MM.yyyy HH") $date0 = (Get-Date).AddHours(0).ToString("dd.MM.yyyy HH") </code></pre> <p>yes, I know this is overkill, I did add "AddHours(0)" for cosmetics :-) As you see, I translate the output value to the desired formatting so that I can use it for -pattern later on.</p> <p>For each object that is checked for 2h until now. As you see, I had to use the -pattern parameter to match multiple values in "OR" logic statement:</p> <pre><code>Get-Content $Path1| Select-String -Pattern $date2, $date1, $date0 | Select-String "FA OK" | Measure-Object -line | out-file $npath -Append Get-Content $Path1 | Select-String -Pattern $date2, $date1, $date0 | Select-String "FA OK" | Select -last 1 | out-file $npath -Append Get-Content $1076 | Select-String -Pattern $date2, $date1, $date0 | Select-String "Status now" | Select -last 1 | out-file $npath -Append </code></pre> <p>The difference for 24h timeframe was that I just modify the .ToString value so that it changes the day in log file entry to look for. The problem occurs when the log rolls over, but it happens like once in 2 months so not much of an issue. Could be worth implementing if the script is to be perfect, but it does its job. </p> <p>I would like to thank you who have taken a look on this matter and provided some input, this was a great help to make first steps in PowerShell that actually do something time-saving. :-)</p> <p>Thank you!</p> <p>Koliat</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload