Created
December 30, 2020 22:11
-
-
Save bill-long/5611fd6972a4dfe3b1a01808c09bbfb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Attach-OnProcessStart | |
$ProcessName = "notepad.exe" | |
$ExceptionFilter = "ScanQueueTimeoutException" | |
Register-CimIndicationEvent -ClassName Win32_ProcessStartTrace -SourceIdentifier "ProcessStarted" | |
while ($true) { | |
$e = @(Get-Event) | |
if ($e.Count -lt 1) { | |
continue | |
} | |
$e | ForEach-Object { | |
Write-Host $_.SourceEventArgs.NewEvent.ProcessID ":" $_.SourceEventArgs.NewEvent.ProcessName | |
if ($_.SourceEventArgs.NewEvent.ProcessName -eq $ProcessName) { | |
Start-Process procdump -ArgumentList "-ma -e 1 -f $ExceptionFilter $($_.SourceEventArgs.NewEvent.ProcessID)" | |
} | |
} | |
$e | Remove-Event | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment