IWSManConnectionOptions interface

The ConnectionOptions object is passed to the CreateSession method to provide the user name and password associated with the local account on the remote computer. If no parameters are supplied, then the credentials of the account running the script are set to the default values.

Methods

The IWSManConnectionOptions interface has these methods.

Method Description
IWSManConnectionOptions::get_UserName Sets and gets the user name of a local or a domain account on the remote computer. This property determines the user name for authentication.
IWSManConnectionOptions::put_Password Sets the password of a local or a domain account on the remote computer. This property determines the password for authentication.
IWSManConnectionOptions::put_UserName Sets and gets the user name of a local or a domain account on the remote computer. This property determines the user name for authentication.

Remarks

The ConnectionOptions object corresponds to the IWSManConnectionOptions interface.

If a Windows Remote Management client application is running under impersonation, then a failure occurs if you set the Password property. A client application is a script or other program that sends a request to WinRM on the local or a remote computer. The client application may be running under impersonation because it called a function like ImpersonateClient. An Active Server Page (ASP) or service cannot request a user name and password if the ASP process runs under an account that impersonates a client.

The WSManFlagCredUserNamePassword flag should be set on the WSman.CreateSession call when using the UserName and Password for authentication.

Examples

The following VBScript code example shows how to create a ConnectionOptions object, set the properties for the account on the remote computer, and use it in creating a Session object.

VB
Set objWsman = CreateObject( "Wsman.Automation" )
'Create ConnectionOptions object.
Set objConnectionOptions = objWsman.CreateConnectionOptions
objConnectionOptions.UserName = "johns "
objConnectionOptions.Password = "Dtf#4542?98"
iFlags = objWsman.SessionFlagUseBasic Or _
  objWsman.SessionFlagCredUserNamePassword
Set objSession = objWsman.CreateSession _
  ("https://172.30.168.2", iFlags, objConnectionOptions)
strResource = objSession.Get("winrm/config")

Requirements

   
Windows version Windows Vista Windows Server 2008
Target Platform Windows
Header wsmandisp.h

See Also

About Windows Remote Management

Authentication for Remote Connections

Obtaining Data from a Remote Computer

Obtaining Data from the Local Computer

Scripting in Windows Remote Management

Using Windows Remote Management

WinRM Scripting API