title: PowerShell Get process id using Get-WmiObject -Class Win32_Process
body: <pre><code>[cmdletbinding()]
  param(
      $ComputerName=“comecomputer”,
      $ProcessName = "SomeApp.exe"
       )
  $Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName -Filter "name='$ProcessName'"
  
  foreach ($process in $processes) 
  { 
      $process
  }
  </code></pre>
  
  <p>Above code gets all info about process but there is no clear id.
  I found in <a href="https://stackoverflow.com/questions/25686547/powershell-v2-how-to-get-process-id">this</a> post that you can get process id using <code>$procid=get-process appname |select -expand id</code> which doesn't work.</p>
  
  <p>Error I'm getting: <code>get-process : Cannot find a process with the name "SomeApp.exe". Verify the process name and call the cmdlet again.</code></p>