I need to polish up this script. I need it to run across multiple (5 - all have the log file in the same location) Windows systems. I am having a hard time figuring out how to ensure I can "tail" the log for the entry on all 5 servers simultaneously and return the 'OK'; terminate the job only when the log entry is generated on all 5 servers and not just let's say 4 of them.
Here is what it is meant to do:
- Start a service,
- "Tail" the log file
- Confirm that the log file contains the entry (
$waitfor) - Once the log entry is generated in the Terminate
$serviceB = "my application service"
$logfile2 = "F:\App\log\wrapper.log"
$waitFor = "[4.2.3.GA (build: SVNTag=JBoss_4_2]”
Write-Host "Starting $serviceB"
Start-Service $serviceB
Write-Host "Waiting for $waitFor in $logfile2"
while (!((Get-Content $logfile2 -Tail 30) | ? {$_ -match $waitFor})) {
Start-Sleep -Seconds 5
}
How can I use a foreach loop to accomplish let's say - tail and wait for log entry on all 5 remote systems in a CSV file?