title: How to get pid from identical running processes and pipe the output into if statement
body: <p>I want the script to find two identical processes that are currently running and pipe the PID of the process that matches a defined path in the variable <code>$procName</code> by using the <code>If($_.Path -eq $procName){</code> command.</p>
  <p>After the correct process has been identified based on it's full file path found earlier, I want to use it's unique PID to check whether it is currently <code>suspended or not suspended</code>.</p>
  <p>If all goes well in the current pipe then use it's output value to run one of two commands below:</p>
  <pre><code>If($_.Path -eq $procName) {
      Start-Process cmd.exe -WindowStyle Maximized -ArgumentList &quot;/D /K pssuspend.exe -nobanner $myPID&quot;
  } Else {
      Start-Process cmd.exe -WindowStyle Maximized -ArgumentList &quot;/D /K pssuspend.exe -nobanner -r $myPID&quot;
  }
  </code></pre>
  <p>My issue is the output is the same result no matter if the processes is currently suspended or not
  <code>Start-Process cmd.exe -WindowStyle Maximized -ArgumentList /D /K pssuspend.exe -nobanner -r 18960</code></p>
  <p>This is what I have so far:</p>
  <pre><code>$procName = 'C:\Program Files (x86)\Steam\steamapps\common\rocketleague\Binaries\Win64\RocketLeague.exe'
  $procID = Get-Process -Name 'RocketLeague' | Select-Object -Property Id,Path | ForEach-Object {
      If($_.Path -eq $procName){
          $myPID = $_.Id
          If(Get-ChildItem | Where-Object -FilterScript {$_.Responding -eq $false}) {
              Write-Host Start-Process cmd.exe -WindowStyle Maximized -ArgumentList &quot;/D /K pssuspend.exe -nobanner $myPID&quot;
              } Else {
              Write-Host Start-Process cmd.exe -WindowStyle Maximized -ArgumentList &quot;/D /K pssuspend.exe -nobanner -r $myPID&quot;
          }
      }
  }
  </code></pre>