views:

56

answers:

1

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

+3  A: 

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 :)

x0n
So that goes to say that you'll start your service, run x0n's command, and as the -Action to it, will stop the service.
Marco Shaw