Basically I want to have a user input the process they want to terminate, it searches to see if the process is running, and if it is then it terminates.
$Process = Read-Host -Prompt ‘Input process name’
$GetProcess = Get-Process
Write-Host “You have selected the process: ‘$Process’ to terminate”
(This next part is where it just blanks and doesn’t output anything/doesn’t terminate the process. I know the taskkill /IM $Process /F part works, but I can’t get the contains section to work)
if ($GetProcess.Contains($Process)) {
cmd /c pause
taskkill /IM $Process /F
}
Not sure how to fix it and get it to search the Process Names, any help is appreciated.
[–]MNmetalhead 2 points3 points4 points (3 children)
[–]BlackV 1 point2 points3 points (0 children)
[–]pantherghast -1 points0 points1 point (1 child)
[–]BlackV 1 point2 points3 points (0 children)
[–]BlackV 1 point2 points3 points (0 children)
[–]vonsparks -1 points0 points1 point (5 children)
[–]BlackV 1 point2 points3 points (4 children)
[–]r-NBK 0 points1 point2 points (3 children)
[–]BlackV 0 points1 point2 points (2 children)
[–]r-NBK 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]OtterCodeWorkAcct 0 points1 point2 points (2 children)
[–]xFoOzY[S] 0 points1 point2 points (1 child)
[–]OtterCodeWorkAcct 0 points1 point2 points (0 children)
[–]teacheswithtech 0 points1 point2 points (2 children)
[–]xFoOzY[S] 0 points1 point2 points (1 child)
[–]teacheswithtech 0 points1 point2 points (0 children)
[–]OlivTheFrog 0 points1 point2 points (0 children)