HostUtilities.InvokeOnRunspace(PSCommand, Runspace) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Helper method to invoke a PSCommand on a given runspace. This method correctly invokes the command for these runspace cases:
- Local runspace. If the local runspace is busy it will invoke as a nested command.
- Remote runspace.
- Runspace that is stopped in the debugger at a breakpoint.
Error and information streams are ignored and only the command result output is returned.
This method is NOT thread safe. It does not support running commands from different threads on the provided runspace. It assumes the thread invoking this method is the same that runs all other commands on the provided runspace.
public:
static System::Collections::ObjectModel::Collection<System::Management::Automation::PSObject ^> ^ InvokeOnRunspace(System::Management::Automation::PSCommand ^ command, System::Management::Automation::Runspaces::Runspace ^ runspace);
public static System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject> InvokeOnRunspace (System.Management.Automation.PSCommand command, System.Management.Automation.Runspaces.Runspace runspace);
static member InvokeOnRunspace : System.Management.Automation.PSCommand * System.Management.Automation.Runspaces.Runspace -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>
Public Shared Function InvokeOnRunspace (command As PSCommand, runspace As Runspace) As Collection(Of PSObject)
Parameters
- command
- PSCommand
Command to invoke.
- runspace
- Runspace
Runspace to invoke the command on.
Returns
Collection of command output result objects.