Skip to content

Instantly share code, notes, and snippets.

@trevor-h
Last active August 29, 2015 14:20
Show Gist options
  • Save trevor-h/18a56725789cbc8ae5dc to your computer and use it in GitHub Desktop.
Save trevor-h/18a56725789cbc8ae5dc to your computer and use it in GitHub Desktop.
function Find-ChildProcess {
param($ID=$PID)
$CustomColumnID = @{
Name = 'Id'
Expression = { [Int[]]$_.ProcessID }
}
$result = Get-WmiObject -Class Win32_Process -Filter "ParentProcessID=$ID" | Select-Object -Property ProcessName, $CustomColumnID, CommandLine
$result
$result | Where-Object { $_.ID -ne $null } | ForEach-Object {
Find-ChildProcess -id $_.Id
}
}
Write-Host $args[0]
$jobid=$args[0]
$procid=c:\salt\salt-call.exe saltutil.find_job $jobid --out=key | Where { $_.contains("pid") } | % { ($_.split(":")[1]).trim() }
Find-ChildProcess $procid | Stop-Process -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment