Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In powershell, is there a difference between:

ps theProcessName* | kill

and

kill -processname theProcessName*

Thanks

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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

share|improve this answer
1  
powershell, not bash; –  Hyppy Jun 18 '12 at 13:52
    
right, I edited my question that it's in powershell –  jon Jun 18 '12 at 14:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.