---
title: "Test-DbaEndpoint"
description: "Tests network connectivity to SQL Server endpoint TCP listener ports."
url: "https://dbatools.io/Test-DbaEndpoint/"
availability: "Windows, Linux, macOS"
tags: ["Endpoint"]
author: "Chrissy LeMaire (@cl), netnerds.net"
source: "https://github.com/dataplat/dbatools/blob/master/public/Test-DbaEndpoint.ps1"
last_updated: "2024-01-01"
---

# Test-DbaEndpoint

## Synopsis

Tests network connectivity to SQL Server endpoint TCP listener ports.

## Description

Tests network connectivity to SQL Server endpoint TCP listener ports by attempting direct socket connections. This function validates that endpoint ports are accessible from the network level, which is essential for troubleshooting database mirroring, Service Broker, and availability group connectivity issues.  
  
The function tests both standard TCP ports and SSL ports when configured, returning connection status rather than endpoint functionality. Endpoints without TCP listener ports (such as HTTP endpoints) are automatically skipped during testing.  
  
Use this when diagnosing connectivity problems between SQL Server instances or validating firewall rules before setting up features that rely on endpoints.

## Syntax

```powershell
Test-DbaEndpoint
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Endpoint] <String[]>]
    [[-InputObject] <Endpoint[]>]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Tests all endpoints on the local default SQL Server instance

```powershell
PS C:\> Test-DbaEndpoint -SqlInstance localhost
```

Tests all endpoints on the local default SQL Server instance.  
Note that if an endpoint does not have a tcp listener port, it will be skipped.  

### Example 2: Tests all endpoints named Mirroring on sql2016 and localhost

```powershell
PS C:\> Get-DbaEndpoint -SqlInstance localhost, sql2016 -Endpoint Mirror | Test-DbaEndpoint
```

Tests all endpoints named Mirroring on sql2016 and localhost.  
Note that if an endpoint does not have a tcp listener port, it will be skipped.  

### Example 3: Tests all endpoints named Mirroring on sql2016 and localhost

```powershell
PS C:\> Test-DbaEndpoint -SqlInstance localhost, sql2016 -Endpoint Mirror
```

Tests all endpoints named Mirroring on sql2016 and localhost.  
Note that if an endpoint does not have a tcp listener port, it will be skipped.  

### Example 4: Tests all endpoints on the local default SQL Server instance

```powershell
PS C:\> Test-DbaEndpoint -SqlInstance localhost -Verbose
```

Tests all endpoints on the local default SQL Server instance.  
See all endpoints that were skipped due to not having a tcp listener port.  

### Optional Parameters

##### -SqlInstance

The target SQL Server instance or instances.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).  
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.  
For MFA support, please use Connect-DbaInstance.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Endpoint

Specifies which endpoint names to test for network connectivity. Accepts multiple endpoint names to filter testing to specific endpoints.  
Use this when you need to validate connectivity for particular endpoints like database mirroring, Service Broker, or availability group listeners instead of testing all endpoints on the instance.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -InputObject

Accepts endpoint objects from Get-DbaEndpoint for pipeline processing. This allows you to filter endpoints first using Get-DbaEndpoint, then test only those specific endpoints.  
Use this approach when you need to apply complex filtering logic before testing connectivity, such as testing only endpoints of a specific type or state.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | true (ByValue) |
| Default Value |  |

##### -EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.  
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.  
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

## Outputs

**PSCustomObject**

Returns one object per endpoint that has a TCP listener port. Each object contains the connection test results for both TCP and SSL connections.

**Properties:**

- ComputerName: The computer name of the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Endpoint: The name of the endpoint being tested
- Port: The TCP listener port for the endpoint
- Connection: TCP connection status - "Success" for successful connection, or error message/exception if connection failed
- SslConnection: SSL connection status - "Success" for successful SSL connection, "None" if no SSL port configured, or error message/exception if SSL connection failed
Endpoints without TCP listener ports are automatically skipped and do not produce output.

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
