0

In powershell, is there a difference between:

ps theProcessName* | kill

and

kill -processname theProcessName*

Thanks

jon
  • 113
  • 2

2 Answers2

2

Effectively, the answer is "no."

ps [processname] | kill will query for a list of objects matching 'processname' and pass those objects to the kill command.

kill -processname [processname] will kill all processes matching 'processname'.

The only difference is how the commands work on the backend. For ps [processname] | kill, Powershell will first perform a Get-Process command, then pass it to kill. kill -processname [processname] will simply issue a Stop-Process command, without querying for their existence first.

Short answer: they will both perform the same task. the straight kill command is very slightly faster, because one step is skipped.

Hyppy
  • 15,608
  • 1
  • 38
  • 59
1

Well, "ps processname" doesn't do anything. And "kill -p" doesn't kill. It prints.

MichaelB
  • 541
  • 4
  • 10