This script kill all instances of the process “Robocopy”

Script :

(get-process |where {$_.processname -eq "Robocopy"}) | stop-process

Reference :
Using the Stop-Process Cmdlet
Terminating a Process


      Stop-Process -name string[] [-passThru] [-Force]
            [-confirm] [-whatIf] [CommonParameters]
      Stop-Process [-id] Int32[] [-passThru] [-Force]
            [-confirm] [-whatIf] [CommonParameters]
      Stop-Process -inputObject Process[] [-passThru] [-Force]
            [-confirm] [-whatIf] [CommonParameters]

Process name(s)
Separate multiple process names with commas or use wildcard characters.

-id Int32
Process ID(s) (PID). Use commas to separate multiple PIDs.
To find the PID of a process, type “get-process”.

Accept a process object as input to Stop-Process.
A variable, command or expression that returns the process object(s)

Pass the object created by Stop-Process along the pipeline.

Stop the specified processes without prompting for confirmation.
By default, Stop-Process prompts for confirmation before stopping
any process that is not owned by the current user.

To find the owner of a process, use Get-WmiMethod to get
a Win32_Process object that represents the process, and then
use the GetOwner method of the object.

Describe what would happen if you executed the command without
actually executing the command.

Prompt for confirmation before executing the command.

-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.

Stop-Process enables you to terminate a process (or processes). You can indicate the processes you want to kill either by specifying the process ID or by specifying the process name. For example, this command stops the process with the process ID 3512:

Stop-Process 3512

To stop a process by process name, use the -processname parameter followed by the process name (minus the file extension). For example, to terminate all instances of Notepad use this command:

Stop-Process -processname notepad

And, yes, Stop-Process accepts wildcard characters, too. For example, this command terminates any instances of Notepad, as well as any other processes whose names start with note:

Stop-Process -processname note*

Stop-Process Aliases

Kill all instances of the same process name

Leave a Reply

Your email address will not be published.