5

The command Test-Cluster is producing an output as a xml and htm file.

$v = test-cluster -Node w16-sqlcA,w16-sqlcB -Include "Storage" -Force -Disk $csv -Verbose

Seems like only way to get the detailed result is by parsing the xml. I have to get the Name of the activity and result of it as if it is shown in the below htm file.

enter image description here

Is there any built-in way of getting it? (or is already a parser is written for test-cluster result?. I searched and found none). Please help.

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
  • 1
    Is there any way for me to replicate this without having my own cluster? – Jacob Colvin Jun 18 '18 at 14:56
  • 1
    @JacobColvin if hyperV is enabled and virtual disk are created ,this might be possible . But if simply running cluster cmdlets how it will behave i am yet to check – Samselvaprabu Jun 19 '18 at 08:56
  • 1
    Hm unfortunately I don't have the resources to check. If you had some way to allow us to replicate, or if there was some way to serialize the output, I bet you'd get an answer right away. – Jacob Colvin Jun 19 '18 at 15:24

1 Answers1

0

When you run a test, an xml file with the results gets generated in C:\Windows\Cluster\Reports

You can use this function to check how many tests have a specific result status

function Get-ClusterValidationResultCount
{
    param(
        [Parameter(Mandatory = $true)]
        [ValidateSet('Failed','Warning','Success','Not Applicable', 'Canceled')]
        [String]
        $Status
    )

    $validationFile = (Get-ChildItem C:\Windows\Cluster\Reports -Filter "Validation Data*.xml" | Select -First 1).FullName
    if ([string]::IsNullOrEmpty("$validationFile")) {
        throw "No validation xml found"
    }

    $results = Select-Xml -Path "$validationFile" -XPath "//ResultDescription" | Where-Object { $_.Node.Value."#cdata-section" -eq $Status }
    return $results.Count
}

Get-ClusterValidationResultCount -Status Failed 
vbranden
  • 5,814
  • 2
  • 22
  • 15