title: How to know if PowerShell script is being run with RunspaceInvoke
body: <p>I have a PowerShell script that needs to run normally, and also when invoked via RunspaceInvoke, e.g.</p>
  
  <pre><code>using (RunspaceInvoke invoker = new RunspaceInvoke())
  {
      invoker.Invoke(powerShellScript);
  }
  </code></pre>
  
  <p>Part of this script doesn't need to run when being called with RunspaceInvoke, and moreover, it fails when being called with RunspaceInvoke.</p>
  
  <p>Is there a way to detect (from within PowerShell) whether the script is being called with RunspaceInvoke?</p>
  
  <p>Thanks</p>