How to make powershell wait for event log entries?

I need to create a component in a larger pipeline that starts the vpn service and waits until the connection is established. I would like to do this with Powershell, if possible. I suppose the logical flow is something similar, but the multithreaded aspect annoys us.

create an event log handler;
start the service;
wait for the entry in the event log to appear

+3
source share
1 answer

PowerShell v2:

Register-WmiEvent -Query "Select * from __InstanceCreationEvent Where TargetInstance ISA 'Win32_NTLogEvent'" -Action { [console]::beep() }

The script in the action block is executed every time an event is written in the eveng log. Expect a lot of beeps :)

+4
source

Source: https://habr.com/ru/post/1731578/


All Articles