Search code examples
powershellpowershell-3.0

Use Get-Process incorrectly piped to Stop-Process


I am trying to stop multiple chrome instances in one row through powershell but get a strange behaviour :

Get-Process -Name chrome | stop-process $_

Returns an error:

Cannot link paramter Id because it is null.

But I have 8 processes running, and I can issue a stop-process on the first one.

So I do not understand what's going on. (Windows 7) Any ideas ?


Solution

  • Just pipe Get-Process cmdlet it to the Stop-Process and omit the $_:

    Get-Process -Name chrome | stop-process