WSManConnectShell function (wsman.h)
Connects to an existing server session.
Syntax
void WSManConnectShell(
[in, out] WSMAN_SESSION_HANDLE session,
DWORD flags,
[in] PCWSTR resourceUri,
[in] PCWSTR shellID,
[in, optional] WSMAN_OPTION_SET *options,
[in, optional] WSMAN_DATA *connectXml,
[in] WSMAN_SHELL_ASYNC *async,
[out] WSMAN_SHELL_HANDLE *shell
);
Parameters
[in, out] session
Specifies the session handle returned by a WSManCreateSession function. This parameter cannot be NULL.
flags
Reserved for future use. Must be zero.
[in] resourceUri
Defines the shell type to which the connection will be made. The shell type is defined by a unique URI, therefore the shell object returned by the call is dependent on the URI that is specified by this parameter. The resourceUri parameter cannot be NULL and it is a null-terminated string.
[in] shellID
Specifies the shell identifier that is associated with the server shell session to which the client intends to connect.
[in, optional] options
A pointer to a WSMAN_OPTION_SET structure that specifies a set of options for the shell. This parameter is optional.
[in, optional] connectXml
A pointer to a WSMAN_DATA structure that defines an open context for the connect shell operation. The content should be a valid XML string. This parameter can be NULL.
[in] async
Defines an asynchronous structure that contains an optional user context and a mandatory callback function. See the WSMAN_SHELL_ASYNC structure for more information. This parameter cannot be NULL.
[out] shell
Specifies a shell handle that uniquely identifies the shell object that was returned by resourceURI. The resource handle tracks the client endpoint for the shell and is used by other WinRM methods to interact with the shell object. The shell object should be deleted by calling the WSManCloseShell method. This parameter cannot be NULL.
Return value
None
Remarks
Connects to an existing server shell session identified by the ShellId parameter. This builds the necessary client side context, represented by the return parameter shell, that can be used to carry out subsequent operations such as running commands and sending and receiving output on the server shell session. This WSManConnectShell function does not automatically construct the client side contexts for any commands that are currently associated with the server shell session.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 8 |
Minimum supported server | Windows Server 2012 |
Target Platform | Windows |
Header | wsman.h |
Library | WsmSvc.lib |
DLL | WsmSvc.dll |
Redistributable | WinRM on Windows Server 2012. |