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