Redigera

Dela via


Session Constants

The session constants in the __WSManSessionFlags enumeration specify authentication and other information for WSMan.CreateSession or IWSMan::CreateSession calls that connect to a remote computer. These constants are also closely related to Winrm command-line tool switches.

Using Session Constants

You can set the Session flags for the call to WSMan.CreateSession in two different ways. One is shorter and simpler. The longer way, as is shown in the following example, is to locate the value of the flag you want to use and create a constant in your script with that value. Then the constant is used to set the value of the iFlags parameter.

Const SessionFlagUseNegotiate = 131072
Const SessionFlagCredUserNamePassword = 4096
iFlags = SessionFlagUseNegotiate Or SessionFlagCredUserNamePassword

The recommended way, as shown in the following example, is to use the WSMan object method associated with the flag.

iFlags = Wsman.SessionFlagUseNegotiate Or Wsman.SessionFlagCredUserNamePassword

Authentication Constants

Specify the authentication method and how to handle certificate servers.

Other Session Constants

Specify the encoding, encryption, and service principal name port.

WinRM Constants and Enumerations

WSMan.CreateSession

Authentication for Remote Connections