diff --git a/private/functions/Get-ResourceGroupState.ps1 b/private/functions/Get-ResourceGroupState.ps1 index 97df6948d16..d43dd0e1211 100644 --- a/private/functions/Get-ResourceGroupState.ps1 +++ b/private/functions/Get-ResourceGroupState.ps1 @@ -4,6 +4,8 @@ function Get-ResourceGroupState ($state) { 0 { "Online" } 1 { "Offline" } 2 { "Failed" } + 3 { "PartialOnline" } + 4 { "Pending" } default { $state } } } diff --git a/public/Get-DbaWsfcResourceGroup.ps1 b/public/Get-DbaWsfcResourceGroup.ps1 index d7a23aa438c..245709ad78a 100644 --- a/public/Get-DbaWsfcResourceGroup.ps1 +++ b/public/Get-DbaWsfcResourceGroup.ps1 @@ -6,7 +6,7 @@ function Get-DbaWsfcResourceGroup { .DESCRIPTION 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. - 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. + 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. All Windows Server Failover Clustering (Wsfc) commands require local admin on each member node. @@ -48,7 +48,7 @@ function Get-DbaWsfcResourceGroup { - ClusterName: The name of the Windows Server Failover Cluster - ClusterFqdn: The fully qualified domain name of the cluster - Name: The name of the resource group - - State: Current resource group state (Online, Offline, Failed, or Unknown) + - State: Current resource group state (Online, Offline, Failed, PartialOnline, Pending, or Unknown) - PersistentState: The desired persistent state of the resource group - OwnerNode: The cluster node that currently owns this resource group diff --git a/public/Get-DbaWsfcRole.ps1 b/public/Get-DbaWsfcRole.ps1 index 6de8328959c..deb613da036 100644 --- a/public/Get-DbaWsfcRole.ps1 +++ b/public/Get-DbaWsfcRole.ps1 @@ -40,7 +40,7 @@ function Get-DbaWsfcRole { - ClusterFqdn: Fully qualified domain name of the cluster - Name: Name of the resource group (key property), typically the cluster role name (e.g., SQL Server instance name) - OwnerNode: Name of the node currently hosting this resource group - - State: Current state of the resource group translated to readable format (Online, Offline, Failed, or Unknown) + - State: Current state of the resource group translated to readable format (Online, Offline, Failed, PartialOnline, Pending, or Unknown) Additional properties available (from WMI MSCluster_ResourceGroup object): - Caption: Short textual description of the resource group diff --git a/tests/Get-DbaWsfcResourceGroup.Tests.ps1 b/tests/Get-DbaWsfcResourceGroup.Tests.ps1 index fa9e86b518d..15157fd7f72 100644 --- a/tests/Get-DbaWsfcResourceGroup.Tests.ps1 +++ b/tests/Get-DbaWsfcResourceGroup.Tests.ps1 @@ -19,6 +19,21 @@ Describe $CommandName -Tag UnitTests { Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $hasParameters | Should -BeNullOrEmpty } } + + InModuleScope dbatools { + Context "Translating resource group states" { + It "Names every state a resource group can report" { + # MSCluster_ResourceGroup.State: a group with one resource offline is PartialOnline (3), a group + # in transition is Pending (4). Both used to come back as the bare number. + Get-ResourceGroupState -1 | Should -Be "Unknown" + Get-ResourceGroupState 0 | Should -Be "Online" + Get-ResourceGroupState 1 | Should -Be "Offline" + Get-ResourceGroupState 2 | Should -Be "Failed" + Get-ResourceGroupState 3 | Should -Be "PartialOnline" + Get-ResourceGroupState 4 | Should -Be "Pending" + } + } + } } Describe $CommandName -Tag IntegrationTests { @@ -41,7 +56,7 @@ Describe $CommandName -Tag IntegrationTests { } It "Translates the state of every resource group" { - $untranslatedGroups = ($wsfcResourceGroups | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed" }).Name + $untranslatedGroups = ($wsfcResourceGroups | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed", "PartialOnline", "Pending" }).Name $untranslatedGroups | Should -BeNullOrEmpty } diff --git a/tests/Get-DbaWsfcRole.Tests.ps1 b/tests/Get-DbaWsfcRole.Tests.ps1 index 7b456257195..2a5a184bc97 100644 --- a/tests/Get-DbaWsfcRole.Tests.ps1 +++ b/tests/Get-DbaWsfcRole.Tests.ps1 @@ -42,7 +42,7 @@ Describe $CommandName -Tag IntegrationTests { It "Translates the state of every role" { # The state was read from $resource.State, a variable this command never assigns, so it # was empty for every role on every cluster. - $untranslatedRoles = ($wsfcRoles | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed" }).Name + $untranslatedRoles = ($wsfcRoles | Where-Object { $PSItem.State -notin "Unknown", "Online", "Offline", "Failed", "PartialOnline", "Pending" }).Name $untranslatedRoles | Should -BeNullOrEmpty }