Bagikan melalui


PowerShell.Create Method

Definition

Overloads

Create()

Constructs an empty PowerShell instance; a script or command must be added before invoking this instance.

Create(RunspaceMode)

Constructs an empty PowerShell instance; a script or command must be added before invoking this instance.

Create(InitialSessionState)

Constructs an empty PowerShell instance; a script or command must be added before invoking this instance.

Create(Runspace)

Constructs an empty PowerShell instance and associates it with the provided Runspace; a script or command must be added before invoking this instance.

Create()

Constructs an empty PowerShell instance; a script or command must be added before invoking this instance.

public:
 static System::Management::Automation::PowerShell ^ Create();
public static System.Management.Automation.PowerShell Create ();
static member Create : unit -> System.Management.Automation.PowerShell
Public Shared Function Create () As PowerShell

Returns

An instance of PowerShell.

Applies to

Create(RunspaceMode)

Constructs an empty PowerShell instance; a script or command must be added before invoking this instance.

public:
 static System::Management::Automation::PowerShell ^ Create(System::Management::Automation::RunspaceMode runspace);
public static System.Management.Automation.PowerShell Create (System.Management.Automation.RunspaceMode runspace);
static member Create : System.Management.Automation.RunspaceMode -> System.Management.Automation.PowerShell
Public Shared Function Create (runspace As RunspaceMode) As PowerShell

Parameters

runspace
RunspaceMode

Runspace mode.

Returns

An instance of PowerShell.

Applies to

Create(InitialSessionState)

Constructs an empty PowerShell instance; a script or command must be added before invoking this instance.

public:
 static System::Management::Automation::PowerShell ^ Create(System::Management::Automation::Runspaces::InitialSessionState ^ initialSessionState);
public static System.Management.Automation.PowerShell Create (System.Management.Automation.Runspaces.InitialSessionState initialSessionState);
static member Create : System.Management.Automation.Runspaces.InitialSessionState -> System.Management.Automation.PowerShell
Public Shared Function Create (initialSessionState As InitialSessionState) As PowerShell

Parameters

initialSessionState
InitialSessionState

InitialSessionState with which to create the runspace.

Returns

An instance of PowerShell.

Applies to

Create(Runspace)

Constructs an empty PowerShell instance and associates it with the provided Runspace; a script or command must be added before invoking this instance.

public static System.Management.Automation.PowerShell Create (System.Management.Automation.Runspaces.Runspace runspace);
static member Create : System.Management.Automation.Runspaces.Runspace -> System.Management.Automation.PowerShell
Public Shared Function Create (runspace As Runspace) As PowerShell

Parameters

runspace
Runspace

Runspace in which to invoke commands.

Returns

An instance of PowerShell.

Remarks

The required Runspace argument is accepted no matter what state it is in. Leaving Runspace state management to the caller allows them to open their runspace in whatever manner is most appropriate for their application (in another thread while this instance of the PowerShell class is being instantiated, for example).

Applies to