Functions/Process/Stop-ProcessByHandle.ps1
Function Stop-ProcessByHandle { [CmdletBinding()] Param ( # Handle of Process to Kill [Parameter(Mandatory=$true)] $Handle, # Quiet Mode [Parameter(Mandatory=$false)] [switch] $Quiet = $false ) Process { try { # Gather Process Info for this Handle $PROC = Get-ProcessByHandle -Handle $Handle if ($PROC.HasExited -eq $FALSE) { $PROC | Stop-Process -Force if(!$quiet){Write-Host "Killed $($Proc.ProcessName) Process" -ForegroundColor Yellow} $PROC = $NULL } } catch {$NULL} } } |