diff --git a/Stop-Process.ps1 b/Stop-Process.ps1 index 47d2176..398dba7 100644 --- a/Stop-Process.ps1 +++ b/Stop-Process.ps1 @@ -1,37 +1 @@ -Function Remediation-StopProcess -{ -param( - [string]$Name, - [switch]$Force=$false -) - -If ( $Name ) -{ - ## Get all matching processes - $Processes = Get-Process | Where { $_.Name -ilike $Name } - - ## Get the total number of matching processes - $NumMatches = $Processes.Count - - If ( $NumMatches -ge 1 ) - { - ## Forcefully close matching processes - If ( $Force ) - { - Foreach ( $proc in $Processes ) { Stop-Process $proc -Force -ErrorAction SilentlyContinue } - Write-Output "Forcefully closed ${NumMatches} matching instance(s) of ${Name}" - } - - ## Gracefully close matching processes - Else - { - Foreach ( $proc in $Processes ) { $proc.CloseMainWindow() | Out-Null } - Write-Output "Gracefully closed ${NumMatches} matching instance(s) of ${Name}" - } - } - - Else { Write-Output "No running processes match the name ${Name}" } -} - -Else { Write-Output "No process name was specified!" } -} \ No newline at end of file +End-Process -Name $Name -Force \ No newline at end of file diff --git a/rmm/Stop-Process.ps1 b/rmm/Stop-Process.ps1 new file mode 100644 index 0000000..926dbb7 --- /dev/null +++ b/rmm/Stop-Process.ps1 @@ -0,0 +1,6 @@ +. $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) + +## This is an RMM script variable +$Name = '{[Process Name]}' + +Run-Script -PSLiveScript 'Stop-Process' \ No newline at end of file