PowerShell kill multiple processes PowerShell kill multiple processes powershell powershell

PowerShell kill multiple processes


Your $softwarelist variable looks like a regular expression, but in your Where-Object condition, you're using the -eq operator. I think you want the -match operator:

$softwarelist = 'chrome|firefox|iexplore|opera'get-process |    Where-Object {$_.ProcessName -match $softwarelist} |    stop-process -force

You can also pass multiple processes to Get-Process, e.g.

Get-Process -Name 'chrome','firefox','iexplore','opera' | Stop-Process -Force


# First, create an array of strings.$array =  @("chrome","firefox","iexplore","opera")# Next, loop through each item in your array, and stop the process.foreach ($process in $array){    Stop-Process -Name $process}