Test WSMan - PowerShell


Overview

Test-WSMan is a PowerShell command that tests if a remote computer is configured to use the Windows Remote Management (WS-Management) service. This command is useful for troubleshooting issues related to WS-Management and verifying connectivity.

Syntax

Test-WSMan [[-ComputerName] <String>] [-Port <Int32>] [-Authentication <WSManAuthentication>] [-Proxy <WSManProxy>] [-ConnectionTimeout <TimeSpan>] [-OperationTimeout <TimeSpan>] [-SkipCACheck] [-SkipCNCheck] [-UseSsl] [-AllowRedirection] [-ImpersonationLevel <ImpersonationLevel>]

Options/Flags

| Option | Description | Default |
|—|—|—|
| -ComputerName | Specifies the remote computer to test. | Current computer |
| -Port | Specifies the port to use for the WS-Management connection. | 5985 |
| -Authentication | Specifies the authentication method to use. Valid values are Basic, Negotiate, Kerberos, CredSSP, and Default. | Default |
| -Proxy | Specifies the proxy server to use. | None |
| -ConnectionTimeout | Specifies the amount of time to wait before the connection times out. | 120 seconds |
| -OperationTimeout | Specifies the amount of time to wait before the operation times out. | 180 seconds |
| -SkipCACheck | Instructs the command to skip SSL certificate authority (CA) checking. | False |
| -SkipCNCheck | Instructs the command to skip SSL common name (CN) checking. | False |
| -UseSsl | Specifies whether to use SSL for the WS-Management connection. | True |
| -AllowRedirection | Instructs the command to allow server-side redirection. | True |
| -ImpersonationLevel | Specifies the impersonation level to use. Valid values are Anonymous, Identify, Impersonate, and Delegate. | Impersonate |

Examples

Example 1: Test WS-Management connectivity to a remote computer

Test-WSMan -ComputerName remote-computer

Example 2: Test WS-Management connectivity using Kerberos authentication

Test-WSMan -ComputerName remote-computer -Authentication Kerberos

Example 3: Test WS-Management connectivity over a specific port

Test-WSMan -ComputerName remote-computer -Port 5986

Common Issues

  • Access denied errors can occur if the remote computer is not configured with the WS-Management service or if you do not have the necessary permissions.
  • Connection timeouts can occur if the network is slow or unstable.
  • SSL certificate errors can occur if the remote computer’s certificate is not trusted or if SSL checking is disabled.

Integration

Test-WSMan can be combined with other PowerShell commands to troubleshoot WS-Management issues or automate tasks related to remote management. For example, you can:

  • Use Invoke-WSMan to execute commands remotely after verifying connectivity.
  • Use New-WSManSession to create a persistent WS-Management session for long-running tasks.
  • Invoke-WSMan
  • New-WSManSession
  • Get-WSManInstance