title: Trying to find and kill a process by PowerShell script
body: <p>I have the following script to find the process "dotnet.exe". In my system, I have many dotnet.exe processes running. But I want to kill the "dotnet.exe" which has command line argument  "MyService\Web\argument". I'm trying to do it by the following script. But it doesn't find anything, although I see the process in the Task Manager.</p>
  
  <pre><code>$process = Get-WmiObject Win32_Process | select name, commandline
  
  foreach ($p in $process)
  {
      if ($p.name -contains "dotnet.exe" -and $p.commandline -contains "web")
      {
          $kp =    Get-Process $p;
          $kp.CloseMainWindow();
          if (!$kp.HasExited)
          {
              $kp | Stop-Process -Force
          }
      }
      else
      {
          Write-Host name: $p.name and param: $p.commandline;
      }
  }
  </code></pre>