Export (0) Print
Expand All

IWSManConnectionOptions::UserName property

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. If no value is supplied and the WSManFlagCredUsernamePassword flag is not set, then the user name of the account that is running the script is used.

If the WSManFlagCredUsernamePassword flag is set but no user name is specified, the script prompts the user to enter the user name and password. If no user name and password are entered then an access denied error is returned. For more information, see Authentication for Remote Connections.

This property is read/write.

Syntax


HRESULT put_UserName(
  [in]   BSTR name
);

HRESULT get_UserName(
  [out]  BSTR *name
);

Property value

A string that contains the user name of a local account on the remote computer.

Remarks

The following Visual Basic Scripting Edition code example is used to specify this property.

Set ConnectionOptions = wsman.CreateConnectionOptions
ConnectionOptions.UserName = "<UserName>"

You can supply UserName and Password for a domain account when using Negotiate or Kerberos authentication, or for a local account with Basic authentication. To connect to a local account, the WSMan.CreateSession flags must contain the combination of the WSManFlagUseBasic flag and the WsmanFlagCredUserNamePassword flag. To connect to a domain account, the WSMan.CreateSession flags must contain the combination of the WSManFlagUseNegotiate flag and the WsmanFlagCredUserNamePassword flag, or the combination of the WSManFlagUseKerberos flag and the WsmanFlagCredUserNamePassword flag. For a domain account, UserName must be specified in the form "computer\username", where the "computer" part of the string can be either the name or the IP address. For more information, see Authentication for Remote Connections.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Redistributable

WinRM 1.1 (Windows Server 2003 R2, or Windows Server 2003 with SP1)

Header

Wsmandisp.h

IDL

Wsmandisp.idl

Library

WSManAutomation.lib

DLL

Wsmauto.dll

See also

IWSManConnectionOptions
ConnectionOptions.UserName

 

 

Show:
© 2014 Microsoft