Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By : Donabel Santos
Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By: Donabel Santos

Overview of this book

Table of Contents (21 chapters)
SQL Server 2014 with PowerShell v5 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating and enabling the HADR endpoint


In this recipe, we will create and enable the AlwaysOn endpoint for all the nodes.

Getting ready

For this recipe, we will use port 5022 for the AlwaysOn communication for all the nodes. To ensure that this works, an exception in the firewall needs to be created for this port for all the instances. If you are using an isolated development environment, you need to first turn off the firewall to get this recipe to work, without having to tinker with the firewall.

We are also going to execute the code on all the nodes. For the following recipe to work, PSRemoting needs to be turned on in every node. Log in to each of the nodes, launch PowerShell or PowerShell ISE as an administrator, and enable remoting using the following script:

Enable-PSRemoting -Force

How to do it...

The following steps will create and enable the AlwaysOn endpoint:

  1. Open PowerShell ISE as an administrator.

  2. Add the following script and run it:

    #prompt for credential
    $cred = Get-Credential
    
    #process...