Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions private/functions/Get-ResourceGroupState.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ function Get-ResourceGroupState ($state) {
0 { "Online" }
1 { "Offline" }
2 { "Failed" }
3 { "PartialOnline" }
4 { "Pending" }
default { $state }
}
}
4 changes: 2 additions & 2 deletions public/Get-DbaWsfcResourceGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion public/Get-DbaWsfcRole.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion tests/Get-DbaWsfcResourceGroup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Get-DbaWsfcRole.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down