title: How to find the process ID of a running scheduled task?
body: <p>I can determine running tasks with:</p>
  
  <pre><code>$TaskService    = new-object -ComObject('Schedule.Service')
  $TaskService.connect()
  $TaskFolder = $TaskService.GetFolder('\')
  $TaskFolder.gettasks(1) | ? {$_.state -eq 4}
  </code></pre>
  
  <p>Is there any way to identify the process IDs of those tasks if they start the same program (i.e. process name) as other existing processes?</p>
  
  <p>My goal is a PowerShell script started from a scheduled task that can identify which scheduled task it is running under.  I can easily determine the PoSh processID with <code>$PID</code>, but I don't know how to link that to a particular scheduled task.</p>
  
  <p>Thanks.</p>