title: PowerShell: Another instance of Start-Process is already running
body: <p>There are 2 PowerShell scripts that run at startup, 1 is in my control and the other is out of my control. </p>
  
  <p>Both of our scripts use Start-Process. Strange issue is if both of our Start-Process's happen to execute at the same time, I get the following error from my script:</p>
  
  <pre><code>Start-Process : This command cannot be run due to the error: An instance of the service is already running.
  </code></pre>
  
  <p>Is there a way to see if another "Start-Process" is already running? I know about "Get-Process" but only shows PowerShell running, not which cmdlet is currently running. </p>
  
  <p>I'm not in favor of NOT using Start-Process.</p>
  
  <p>As a temporary workaround, I've told my script to sleep for 60 seconds, but would rather KNOW when the other Start-Process is done.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$pw = ConvertTo-SecureString -AsPlainText -Force -String "myPassword"
  $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "Administrator",$pw
  
  $psArgList = "-ExecutionPolicy Bypass","-file"
  $psArgList += $args
  
  Start-Process powershell.exe -Wait -Credential $cred -ArgumentList $psArgList
  </code></pre>
  
  <p>This allows me to run another PowerShell script with full privileges: as Admin with ExecutionPolicy as Bypass.</p>