JSacksteder
JSacksteder

Reputation: 790

How to make powershell wait on event log entry?

I need to create a component in a larger pipeline that starts vpn service and waits for a connection to be established before proceeding. I'd like to do this with Powershell if possible. I imagine the logic flow being something like this, but the multithreading aspect is vexing me.

create an event log handler
start a service
wait for a specific event log entry
exit

Upvotes: 3

Views: 1936

Answers (1)

x0n
x0n

Reputation: 52420

PowerShell v2:

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

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

Upvotes: 4

Related Questions