Skip to content

Commit 8416146

Browse files
committed
Get-DbaWsfcResourceGroup - Name the PartialOnline and Pending states of a resource group
Get-ResourceGroupState mapped -1/0/1/2 and returned the raw number for everything else, so a group with one resource offline showed State 3 and a group in transition State 4, although the help promised readable names. MSCluster_ResourceGroup documents 3 as PartialOnline and 4 as Pending. Get-DbaWsfcRole reports the same state through the same function. (do *Wsfc*)
1 parent 9d458fd commit 8416146

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

private/functions/Get-ResourceGroupState.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ function Get-ResourceGroupState ($state) {
44
0 { "Online" }
55
1 { "Offline" }
66
2 { "Failed" }
7+
3 { "PartialOnline" }
8+
4 { "Pending" }
79
default { $state }
810
}
911
}

public/Get-DbaWsfcResourceGroup.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function Get-DbaWsfcResourceGroup {
66
.DESCRIPTION
77
Retrieves detailed information about Windows Server Failover Cluster resource groups, including their current state, persistent state, and which node currently owns them. This function helps DBAs monitor and troubleshoot SQL Server Failover Cluster Instances and Availability Groups by providing visibility into the underlying cluster resource groups that control SQL Server services and resources.
88
9-
Use this command when you need to verify resource group health during maintenance windows, troubleshoot failover issues, or confirm which node is currently hosting specific SQL Server resources. The function translates numeric state codes into readable status values (Online, Offline, Failed, Unknown) so you can quickly identify problematic resource groups.
9+
Use this command when you need to verify resource group health during maintenance windows, troubleshoot failover issues, or confirm which node is currently hosting specific SQL Server resources. The function translates numeric state codes into readable status values (Online, Offline, Failed, PartialOnline, Pending, Unknown) so you can quickly identify problematic resource groups.
1010
1111
All Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.
1212
@@ -48,7 +48,7 @@ function Get-DbaWsfcResourceGroup {
4848
- ClusterName: The name of the Windows Server Failover Cluster
4949
- ClusterFqdn: The fully qualified domain name of the cluster
5050
- Name: The name of the resource group
51-
- State: Current resource group state (Online, Offline, Failed, or Unknown)
51+
- State: Current resource group state (Online, Offline, Failed, PartialOnline, Pending, or Unknown)
5252
- PersistentState: The desired persistent state of the resource group
5353
- OwnerNode: The cluster node that currently owns this resource group
5454

public/Get-DbaWsfcRole.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Get-DbaWsfcRole {
4040
- ClusterFqdn: Fully qualified domain name of the cluster
4141
- Name: Name of the resource group (key property), typically the cluster role name (e.g., SQL Server instance name)
4242
- OwnerNode: Name of the node currently hosting this resource group
43-
- State: Current state of the resource group translated to readable format (Online, Offline, Failed, or Unknown)
43+
- State: Current state of the resource group translated to readable format (Online, Offline, Failed, PartialOnline, Pending, or Unknown)
4444
4545
Additional properties available (from WMI MSCluster_ResourceGroup object):
4646
- Caption: Short textual description of the resource group

tests/Get-DbaWsfcResourceGroup.Tests.ps1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ Describe $CommandName -Tag UnitTests {
1919
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $hasParameters | Should -BeNullOrEmpty
2020
}
2121
}
22+
23+
InModuleScope dbatools {
24+
Context "Translating resource group states" {
25+
It "Names every state a resource group can report" {
26+
# MSCluster_ResourceGroup.State: a group with one resource offline is PartialOnline (3), a group
27+
# in transition is Pending (4). Both used to come back as the bare number.
28+
Get-ResourceGroupState -1 | Should -Be "Unknown"
29+
Get-ResourceGroupState 0 | Should -Be "Online"
30+
Get-ResourceGroupState 1 | Should -Be "Offline"
31+
Get-ResourceGroupState 2 | Should -Be "Failed"
32+
Get-ResourceGroupState 3 | Should -Be "PartialOnline"
33+
Get-ResourceGroupState 4 | Should -Be "Pending"
34+
}
35+
}
36+
}
2237
}
2338

2439
Describe $CommandName -Tag IntegrationTests {
@@ -41,7 +56,7 @@ Describe $CommandName -Tag IntegrationTests {
4156
}
4257

4358
It "Translates the state of every resource group" {
44-
$untranslatedGroups = ($wsfcResourceGroups | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed" }).Name
59+
$untranslatedGroups = ($wsfcResourceGroups | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed", "PartialOnline", "Pending" }).Name
4560
$untranslatedGroups | Should -BeNullOrEmpty
4661
}
4762

tests/Get-DbaWsfcRole.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Describe $CommandName -Tag IntegrationTests {
4242
It "Translates the state of every role" {
4343
# The state was read from $resource.State, a variable this command never assigns, so it
4444
# was empty for every role on every cluster.
45-
$untranslatedRoles = ($wsfcRoles | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed" }).Name
45+
$untranslatedRoles = ($wsfcRoles | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed", "PartialOnline", "Pending" }).Name
4646
$untranslatedRoles | Should -BeNullOrEmpty
4747
}
4848

0 commit comments

Comments
 (0)