PowerShellTab.InvokeSynchronousCommand(String, Boolean, Int32) Method

Definition

Invokes the command synchronously returning the results instead of placing them in the output This method is intended for the quick evaluation of a script, with minimal side effects for applications like a watch window.

public:
 System::Collections::ObjectModel::Collection<System::Management::Automation::PSObject ^> ^ InvokeSynchronousCommand(System::String ^ command, bool useNewScope, int millisecondsTimeout);
public System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject> InvokeSynchronousCommand(string command, bool useNewScope, int millisecondsTimeout);
member this.InvokeSynchronousCommand : string * bool * int -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>
Public Function InvokeSynchronousCommand (command As String, useNewScope As Boolean, millisecondsTimeout As Integer) As Collection(Of PSObject)

Parameters

command
String

The command to run.

useNewScope
Boolean

True to use a new scope

millisecondsTimeout
Int32

The number of milliseconds to wait, or a negative value like TimeOut.Infinite to wait indefinitely.

Returns

The results of running the script.

Exceptions

if command is null.

if a command is already running.

For any errors executing the command. If multiple errors are found running the script, only the first will be thrown as an exception.

If millisecondsTimeout have passed and the command has not completed.

Applies to