---
title: "Create a Database Mirroring Endpoint for AlwaysOn Availability Groups (SQL Server PowerShell) | Microsoft Docs"
ms.custom: ""
ms.date: "06/13/2017"
ms.prod: "sql-server-2014"
ms.reviewer: ""
ms.technology: high-availability
ms.topic: conceptual
helpviewer_keywords:
- "Availability Groups [SQL Server], server instance"
- "Availability Groups [SQL Server], deploying"
- "Availability Groups [SQL Server], endpoint"
ms.assetid: 6197bbe7-67d4-446d-ba5f-cabfa5df77f1
author: MashaMSFT
ms.author: mathoma
manager: craigg
---
# Create a Database Mirroring Endpoint for AlwaysOn Availability Groups (SQL Server PowerShell)
This topic describes how to create a database mirroring endpoint for use by [!INCLUDE[ssHADR](../../../includes/sshadr-md.md)] in [!INCLUDE[ssCurrent](../../../includes/sscurrent-md.md)] by using PowerShell.
**In This Topic**
- **Before you begin:** [Security](#Security)
- **To create a database mirroring endpoint, using:** [PowerShell](#PowerShellProcedure)
## Before You Begin
### Security
> [!IMPORTANT]
> The RC4 algorithm is deprecated. [!INCLUDE[ssNoteDepFutureDontUse](../../../includes/ssnotedepfuturedontuse-md.md)] We recommend that you use AES.
#### Permissions
Requires CREATE ENDPOINT permission, or membership in the sysadmin fixed server role. For more information, see [GRANT Endpoint Permissions (Transact-SQL)](/sql/t-sql/statements/grant-endpoint-permissions-transact-sql).
## Using PowerShell
**To create a database mirroring endpoint**
1. Change directory (`cd`) to the server instance for which you want to create the database mirroring endpoint.
2. Use the `New-SqlHadrEndpoint` cmdlet to create the endpoint and then use the `Set-SqlHadrEndpoint` to start the endpoint.
### Example (PowerShell)
The following PowerShell commands create a database mirroring endpoint on an instance of SQL Server (*Machine*\\*Instance*). The endpoint uses port 5022.
> [!IMPORTANT]
> This example works only on a server instance that currently lack a database mirroring endpoint.
```powershell
# Create the endpoint.
$endpoint = New-SqlHadrEndpoint MyMirroringEndpoint -Port 5022 -Path SQLSERVER:\SQL\Machine\Instance
# Start the endpoint
Set-SqlHadrEndpoint -InputObject $endpoint -State "Started"
```
## Related Tasks
**To Configure a Database Mirroring Endpoint**
- [Create a Database Mirroring Endpoint for Windows Authentication (Transact-SQL)](../../database-mirroring/create-a-database-mirroring-endpoint-for-windows-authentication-transact-sql.md)
- [Use Certificates for a Database Mirroring Endpoint (Transact-SQL)](../../database-mirroring/use-certificates-for-a-database-mirroring-endpoint-transact-sql.md)
- [Allow a Database Mirroring Endpoint to Use Certificates for Outbound Connections (Transact-SQL)](../../database-mirroring/database-mirroring-use-certificates-for-outbound-connections.md)
- [Allow a Database Mirroring Endpoint to Use Certificates for Inbound Connections (Transact-SQL)](../../database-mirroring/database-mirroring-use-certificates-for-inbound-connections.md)
- [Specify a Server Network Address (Database Mirroring)](../../database-mirroring/specify-a-server-network-address-database-mirroring.md)
- [Specify the Endpoint URL When Adding or Modifying an Availability Replica (SQL Server)](specify-endpoint-url-adding-or-modifying-availability-replica.md)
**To View Information About the Database Mirroring Endpoint**
- [sys.database_mirroring_endpoints (Transact-SQL)](/sql/relational-databases/system-catalog-views/sys-database-mirroring-endpoints-transact-sql)
## See Also
[Create an Availability Group (Transact-SQL)](create-an-availability-group-transact-sql.md)
[Overview of AlwaysOn Availability Groups (SQL Server)](overview-of-always-on-availability-groups-sql-server.md)