File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Kills all local processes matching the given name
4+ . DESCRIPTION
5+ ← enter a detailed description of the script here
6+ .PARAMETER
7+ ← enter the description of a parameter here (repeat the .PARAMETER for each parameter)
8+ . EXAMPLE
9+ ← enter a sample command that uses the script, optionally followed by sample output and a description (repeat the .EXAMPLE for each example)
10+ . NOTES
11+ Author: ← enter full name here
12+ License: ← enter license here
13+ . LINK
14+ ← enter URL to additional information here
15+ #>
16+
17+ [CmdletBinding ()]
18+ param (
19+ # [Parameter(Mandatory,ParameterSetName='ByProcessName')]
20+ [string ]$ProcessName = $ (Read-Host - Prompt ' Enter the process name' ))
21+
22+ function KillProcesses {
23+ Write-Host - BackgroundColor Yellow - ForegroundColor Red " Process to kill: $ProcessName "
24+ Get-Process | Where-Object - FilterScript {$_.processname -eq $ProcessName } | Select-Object id | Stop-Process
25+ }
26+
27+
28+ try {
29+ KillProcesses - ProcessName $processName
30+ " ✔️ Done."
31+ exit 0 # success
32+ } catch {
33+ " ⚠️ Error in line $ ( $_.InvocationInfo.ScriptLineNumber ) : $ ( $Error [0 ]) "
34+ exit 1
35+ }
You can’t perform that action at this time.
0 commit comments