DBA Hub

📋Steps in this guide1/13

Windows Server 2022 Failover Cluster using PowerShellfor SQL Server Always On Availability Groups

Windows Server 2022 Failover Cluster using PowerShell for SQL Server Always On Availability Groups

sqlserver clusteringintermediate
by MSSQL
15 views
1

1. Prerequisites

- All four servers must run Windows Server 2022 . - All servers must be joined to the same Active Directory domain . - Ensure proper DNS name resolution between all nodes. - Verify network connectivity and configure static IP addresses . - Install the latest Windows updates and vendor drivers.
2

2. Install Failover Clustering Feature

Run the following command on each node as Administrator.
3

On NTICBPSQLSGV01

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV01
PS C:\Users\Administrator>
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed

PS C:\Users\Administrator>
4

On NTICBPSQLSGV02

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV02
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed


PS C:\Users\Administrator>
5

On NTICBPSQLSGV03

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV03
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed

PS C:\Users\Administrator>
6

On NTICBPSQLSGV04

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS C:\Users\Administrator> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools                     
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Failover Clustering, Remote Server Admini...


PS C:\Users\Administrator> hostname
NTICBPSQLSGV04
PS C:\Users\Administrator> Get-WindowsFeature -Name Failover-Clustering

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] Failover Clustering                                 Failover-Clustering            Installed


PS C:\Users\Administrator>
7

On NTICBPSQLSGV01

Load the Windows Failover Clustering PowerShell module into your current PowerShell session. Run validation before creating the cluster: Note:
Step 7

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
On NTICBPSQLSGV01:

PS C:\Users\Administrator> hostname
NTICBPSQLSGV01
PS C:\Users\Administrator> Import-Module FailoverClusters
PS C:\Users\Administrator>

PS C:\Users\Administrator> Test-Cluster -Node NTICBPSQLSGV01,NTICBPSQLSGV02,NTICBPSQLSGV03,NTICBPSQLSGV04
WARNING: System Configuration - Validate Software Update Levels: The test reported some warnings..
WARNING: Network - Validate Network Communication: The test reported some warnings..
WARNING:
Test Result:
HadUnselectedTests, ClusterConditionallyApproved
Testing has completed for the tests you selected. You should review the warnings in the Report.  A cluster solution is
supported by Microsoft only if you run all cluster validation tests, and all tests succeed (with or without warnings).
Test report file path: C:\Users\Administrator\AppData\Local\Temp\2\Validation Report 2025.12.29 At 18.28.44.htm

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        12/29/2025   6:34 PM        1346352 Validation Report 2025.12.29 At 18.28.44.htm


PS C:\Users\Administrator>
8

4. Create the Cluster

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
New-Cluster `
 -Name NTICBPSQLSGC05 `
 -Node NTICBPSQLSGV01,NTICBPSQLSGV02,NTICBPSQLSGV03,NTICBPSQLSGV04 `
 -StaticAddress 192.168.2.25 `
 -NoStorage

PS C:\Users\Administrator> New-Cluster `
>>  -Name NTICBPSQLSGC05 `
>>  -Node NTICBPSQLSGV01,NTICBPSQLSGV02,NTICBPSQLSGV03,NTICBPSQLSGV04 `
>>  -StaticAddress 192.168.2.25 `
>>  -NoStorage

Name
----
NTICBPSQLSGC05


PS C:\Users\Administrator>
9

Cluster Name

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
PS C:\Users\Administrator> Get-Cluster

Name
----
NTICBPSQLSGC05


PS C:\Users\Administrator>
10

Cluster Nodes

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
PS C:\Users\Administrator> Get-ClusterNode

Name           State Type
----           ----- ----
NTICBPSQLSGV01 Up    Node
NTICBPSQLSGV02 Up    Node
NTICBPSQLSGV03 Up    Node
NTICBPSQLSGV04 Up    Node


PS C:\Users\Administrator>
11

Cluster Resources

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
PS C:\Users\Administrator> Get-ClusterResource

Name               State  OwnerGroup    ResourceType
----               -----  ----------    ------------
Cluster IP Address Online Cluster Group IP Address
Cluster Name       Online Cluster Group Network Name


PS C:\Users\Administrator>
12

Cluster Network

Step 12

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
PS C:\Users\Administrator> Get-ClusterNetwork | Format-Table Name, Address, Role, State

Name              Address                 Role State
----              -------                 ---- -----
Cluster Network 1 192.168.2.0 ClusterAndClient    Up


PS C:\Users\Administrator>
13

6. Add Witness

In this test lab environment, the File Share Witness (FSW) is hosted on the Domain Controller (DC) . Using a Domain Controller as File Share Witness is NOT recommended for production. - In production, the File Share Witness should be hosted on: A dedicated file server Azure Cloud Witness (recommended) - A dedicated file server - Azure Cloud Witness (recommended) - The witness folder must have Full Control for: The Windows Failover Cluster computer object SQL Server Always On cluster name object - The Windows Failover Cluster computer object - SQL Server Always On cluster name object Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.
Step 13

Comments (0)

Please to add comments

No comments yet. Be the first to comment!