< Back
New-CustomAG
Post
NAME New-CustomAG
SYNOPSIS
Creates AlwaysOn availabilty group for servers provided.
SYNTAX
New-CustomAG [-Servers] <String[]> [-SqlAgName] <String> [[-CNO] <String>] [[-AgListenerName] <String>]
[[-SqlAgDatabase] <String>] [[-AgListenerPort] <String>] [[-IPAddresses] <String[]>] [[-AgListenerSubnetMask]
<String>] [-BackupDirectory] <String> [<CommonParameters>]
DESCRIPTION
Utilizes SMO to access SQL Server to backup database and create Availabity Group Based on Params
If SQL Client Tools are not loaded on the machine it will error and fail.
If AlwaysOn is not enabled on the Instance of SQL Server the service will be restarted to enable it. This is
required for it to continue with AG Creation.
If you do not want the service to be recycled enable prior to executing the script.
PARAMETERS
-Servers <String[]>
Servers participating in AlwaysOn, first server will be assumed to be where the database is which needs to be
replicated.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SqlAgName <String>
Availability Group Name database will be created in
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-CNO <String>
Cluster Name Object which was created IN Active Directory. If not passed assumes its derived from server
names.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-AgListenerName <String>
Listener Name to be created that references availability group if no listener is passed it will be created
same as SQLAgname
Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SqlAgDatabase <String>
Database which will be placed in Availability Group. If HADRSeed database will be created and dropped.
Required? false
Position? 5
Default value HADRSeed
Accept pipeline input? false
Accept wildcard characters? false
-AgListenerPort <String>
Port listener will listen on
Required? false
Position? 6
Default value 1433
Accept pipeline input? false
Accept wildcard characters? false
-IPAddresses <String[]>
One or Many Ip addresses which will be tied to the listener. One Ip is required for each subnet
Required? false
Position? 7
Default value
Accept pipeline input? false
Accept wildcard characters? false
-AgListenerSubnetMask <String>
Subnetmask for Listeners (Assumption all will utilize the same subnetmask)
Required? false
Position? 8
Default value 255.255.255.0
Accept pipeline input? false
Accept wildcard characters? false
-BackupDirectory <String>
Backup location which all nodes will have access to. Used to backup and restore database from.
Required? true
Position? 9
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Creates Availability Group AG-TNTNTX10 for three servers cross subnet
New-CustomAG -Servers TNSQL5010,TNSQL5011,TXSQL5010 -SqlAgName AG-TNTNTX10 -IPAddresses
192.168.81.211,192.168.91.212 -BackupDirectory \\\\ohnas001\\SQLBackups
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>New-CustomAG -Servers TNSQL5010,TNSQL5011,TXSQL5010,WASQL5010 -SqlAgName AG-TNTXWA5001 -CNO CNOTNTNTX5010
-IPAddresses 192.168.81.31,192.168.91.31,192.168.71.31 -BackupDirectory \\\\ohnas001\\SQLBackups -verbose
RELATED LINKS
SYNOPSIS
Creates AlwaysOn availabilty group for servers provided.
SYNTAX
New-CustomAG [-Servers] <String[]> [-SqlAgName] <String> [[-CNO] <String>] [[-AgListenerName] <String>]
[[-SqlAgDatabase] <String>] [[-AgListenerPort] <String>] [[-IPAddresses] <String[]>] [[-AgListenerSubnetMask]
<String>] [-BackupDirectory] <String> [<CommonParameters>]
DESCRIPTION
Utilizes SMO to access SQL Server to backup database and create Availabity Group Based on Params
If SQL Client Tools are not loaded on the machine it will error and fail.
If AlwaysOn is not enabled on the Instance of SQL Server the service will be restarted to enable it. This is
required for it to continue with AG Creation.
If you do not want the service to be recycled enable prior to executing the script.
PARAMETERS
-Servers <String[]>
Servers participating in AlwaysOn, first server will be assumed to be where the database is which needs to be
replicated.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SqlAgName <String>
Availability Group Name database will be created in
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-CNO <String>
Cluster Name Object which was created IN Active Directory. If not passed assumes its derived from server
names.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-AgListenerName <String>
Listener Name to be created that references availability group if no listener is passed it will be created
same as SQLAgname
Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SqlAgDatabase <String>
Database which will be placed in Availability Group. If HADRSeed database will be created and dropped.
Required? false
Position? 5
Default value HADRSeed
Accept pipeline input? false
Accept wildcard characters? false
-AgListenerPort <String>
Port listener will listen on
Required? false
Position? 6
Default value 1433
Accept pipeline input? false
Accept wildcard characters? false
-IPAddresses <String[]>
One or Many Ip addresses which will be tied to the listener. One Ip is required for each subnet
Required? false
Position? 7
Default value
Accept pipeline input? false
Accept wildcard characters? false
-AgListenerSubnetMask <String>
Subnetmask for Listeners (Assumption all will utilize the same subnetmask)
Required? false
Position? 8
Default value 255.255.255.0
Accept pipeline input? false
Accept wildcard characters? false
-BackupDirectory <String>
Backup location which all nodes will have access to. Used to backup and restore database from.
Required? true
Position? 9
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Creates Availability Group AG-TNTNTX10 for three servers cross subnet
New-CustomAG -Servers TNSQL5010,TNSQL5011,TXSQL5010 -SqlAgName AG-TNTNTX10 -IPAddresses
192.168.81.211,192.168.91.212 -BackupDirectory \\\\ohnas001\\SQLBackups
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>New-CustomAG -Servers TNSQL5010,TNSQL5011,TXSQL5010,WASQL5010 -SqlAgName AG-TNTXWA5001 -CNO CNOTNTNTX5010
-IPAddresses 192.168.81.31,192.168.91.31,192.168.71.31 -BackupDirectory \\\\ohnas001\\SQLBackups -verbose
RELATED LINKS