Share via


New-WSManSessionOption

Applies To: Windows PowerShell 2.0

Creates a WS-Management session option hash table to use as input parameters to the following WS-Management cmdlets: Get-WSManInstance Set-WSManInstance Invoke-WSManAction Connect-WSMan

Syntax

New-WSManSessionOption [-NoEncryption <switch>] [-OperationTimeout <int>] [-ProxyAccessType <ProxyAccessType>] [-ProxyAuthentication <string>] [-ProxyCredential <PSCredential>] [-SkipCACheck <switch>] [-SkipCNCheck <switch>] [-SkipRevocationCheck <switch>] [-SPNPort <int>] [-UseUTF16 <switch>] [<CommonParameters>]

Description

Creates a WSMan Session option hashtable which can be passed into WSMan cmdlets:

Get-WSManInstance

Set-WSManInstance

Invoke-WSManAction

Connect-WSMan

Parameters

-NoEncryption <switch>

Do not use encryption when doing remote operations over HTTP.

Note: Unencrypted traffic is not allowed by default and must be enabled in the local configuration.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-OperationTimeout <int>

Defines the timeout in milliseconds for the WS-Management operation.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ProxyAccessType <ProxyAccessType>

Specifies the mechanism by which the proxy server is located. Possible values are:

ProxyIEConfig - Use the Internet Explorer proxy configuration for the current user. This is the default setting.

ProxyWinHttpConfig - The WSMan client uses the proxy settings configured for WinHTTP, using the ProxyCfg.exe utility.

ProxyAutoDetect - Force auto-detection of a proxy server.

ProxyNoProxyServer - Do not use a proxy server. All all host names will be resolved locally.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ProxyAuthentication <string>

Specifies the authentication method to use at the proxy. Possible values are:

- Basic: Basic is a scheme in which the user name and password are sent in clear-text to the server or proxy.

- Digest: Digest is a challenge-response scheme that uses a server-specified data string for the challenge.

- Negotiate (the default): Negotiate is a challenge-response scheme that negotiates with the server or proxy to determine which scheme to use for authentication. Examples are the Kerberos protocol and NTLM.

Required?

false

Position?

named

Default Value

Negotiate

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ProxyCredential <PSCredential>

Specifies a user account that has permission to gain access through an intermediate web proxy.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SkipCACheck <switch>

Specifies that when connecting over HTTPS, the client does not validate that the server certificate is signed by a trusted certification authority (CA). Use this option only when the remote computer is trusted by other means, for example, if the remote computer is part of a network that is physically secure and isolated or the remote computer is listed as a trusted host in the WS-Management configuration.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SkipCNCheck <switch>

Specifies that the certificate common name (CN) of the server does not need to match the hostname of the server. This is used only in remote operations using HTTPS. This option should only be used for trusted computers.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SkipRevocationCheck <switch>

Do not validate the revocation status on the server certificate.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SPNPort <int>

Specifies a port number to append to the connection Service Principal Name <SPN> of the remote server. An SPN is used when the authentication mechanism is Kerberos or Negotiate.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UseUTF16 <switch>

Encode the request in UTF16 format rather than UTF8 format. The default is UTF8 encoding.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, OutBuffer, OutVariable, WarningAction, and WarningVariable. For more information, see about_CommonParameters.

Inputs and Outputs

The input type is the type of the objects that you can pipe to the cmdlet. The return type is the type of the objects that the cmdlet returns.

Inputs

Outputs

SessionOption

Example 1

C:\PS>$a = New-WSManSessionOption -operationtimeout 30000
Connect-WSMan -computer server01 -sessionoption $a

PS C:\Users\testuser> cd wsman:
PS WSMan:\> 
PS WSMan:\> dir


   WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan

ComputerName                                  Type
------------                                  ----
localhost                                     Container
server01                                      Container

Description
-----------
This command creates a connection to the remote server01 computer by using the connection options that are defined in the New-WSManSessionOption command.

The first command uses the New-WSManSessionOption cmdlet to store a set of connection setting options in the $a variable. In this case, the session options set a connection time out of 30 seconds (30,000 milliseconds).

The second command uses the SessionOption parameter to pass the credentials that are stored in the $a variable to Connect-WSMan. Then, Connect-WSMan connects to the remote server01 computer by using the specified session options.

The Connect-WSMan cmdlet is generally used within the context of the WSMan provider to connect to a remote computer, in this case the server01 computer. However, you can use the cmdlet to establish connections to remote computers before you change to the WSMan provider. Those connections will appear in the ComputerName list.





See Also

Concepts

Connect-WSMan
Disable-WSManCredSSP
Disconnect-WSMan
Enable-WSManCredSSP
Get-WSManCredSSP
Get-WSManInstance
Invoke-WSManAction
New-WSManInstance
Remove-WSManInstance
Set-WSManInstance
Set-WSManQuickConfig
Test-WSMan