Script directory for a PowerShell profile. https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
670 B

  1. [cmdletbinding()]param([string]$ProcessName)
  2. $local:new_KillPIDs = @() + (Get-Process -name $processName | Select-Object -ExpandProperty ID)
  3. $local:KillPIDs = @()
  4. Do {
  5. $KillPIDs += $new_KillPIDs | Where-Object { $_ -notin $KillPIDs }
  6. Write-Verbose "Again"
  7. Write-Verbose $new_KillPIDs -join ", "
  8. $new_KillPIDs = $new_KillPIDs | ForEach-Object { Get-CimInstance -ClassName Win32_Process -Filter "ParentProcessId = $_" } | Select-Object -ExpandProperty ProcessId
  9. } Until ( -not $new_KillPIDs )
  10. Write-Verbose "Done"
  11. start-process powershell -ArgumentList "-command","Stop-Process -Force -Id @($($KillPIDs -join '', ''))" -WindowStyle Minimized