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 an Availability Group listener


In this recipe, we will create an Availability Group listener for an Availability Group.

Getting ready

We will use the following information for this recipe. You will need to change these values based on your environment configuration:

Configuration

Value

Availability Group (AG) Name

SQLAGListener

Primary Replica Instance

SQL01

AG Listener Name

SQLAGListener

AG Listener IP Address

192.168.1.200

AG Listener Subnet Mask

255.255.255.0

AG Listener Port Number

1433

How to do it...

Perform the following steps to create and configure an Availability Group listener:

  1. Open PowerShell ISE as an administrator.

  2. Add the following script and run it:

    Import-Module SQLPS -DisableNameChecking
    
    $AGName = "SQLAG"
    $AGListenerName = "SQLAGListener"
    $AGListenerPort = 1433
    $AGListenerIPAddress = "192.168.1.200"
    $AGListenerSubnetMask = "255.255.255.0"
    $primary = "SQL01"
    
    #server object
    $server = New-Object Microsoft.SqlServer.Management.Smo.Server...