Reputation: 681
I got within my application (process) an already configured c# Runspace v3. I want to execute my PowerShell script in a new process, but within the same Runspace. How could I accomplish this? I thought, when I start a PowerShell within an existing runspace, then that Runspace will be inherited to the new PowerShell: Unfortunately, this was not the case...
I have seen following interesting methods, but got no solution how these could help: RunspaceFactory.CreateOutOfProcessRunspace Invoke-Command
PS: I can not change within my app the access from Runspace to a PowerShellProcessInstance and also I can not use PSRemoting
Upvotes: 1
Views: 903
Reputation: 174990
What you describe is impossible - a single runspace cannot span multiple processes.
Allow me to demonstrate the relevant hierarchical relationships with this state of the art graphic I whipped up in mspaint
:
A runspace is bound to a single .NET AppDomain, and an AppDomain cannot span multiple processes.
Upvotes: 5