In powershell, is there a difference between:
ps theProcessName* | kill
and
kill -processname theProcessName*
Thanks
In powershell, is there a difference between:
ps theProcessName* | kill
and
kill -processname theProcessName*
Thanks
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.
Well, "ps processname" doesn't do anything. And "kill -p" doesn't kill. It prints.