Skip to content

Instantly share code, notes, and snippets.

@nickgarvey
Created June 24, 2018 22:04
Show Gist options
  • Select an option

  • Save nickgarvey/8dcaf761dca9d85a666fce3fbfe2434b to your computer and use it in GitHub Desktop.

Select an option

Save nickgarvey/8dcaf761dca9d85a666fce3fbfe2434b to your computer and use it in GitHub Desktop.
#$global:last_time = 0
$restart = {
#$i = $Args.NewEvent.Properties['TIME_CREATED']
Stop-Process -processname notepad
notepad
$s = Out-String -InputObject $Args.NewEvent.Properties
Write-Host $s
Remove-Event -SourceIdentifier asdf
}
Register-WmiEvent -Action $restart -Query "SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2" -SourceIdentifier asdf
Wait-Event asdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment