powershell - 如何以对象格式获取测试集群输出?

标签 powershell failover failovercluster

命令 Test-Cluster 正在生成输出为 xml 和 htm 文件。

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

似乎获得详细结果的唯一方法是解析 xml。我必须获取事件的名称及其结果,就好像它显示在下面的 htm 文件中一样。

enter image description here

有没有内置的获取方式? (或者已经为测试集群结果编写了解析器?我搜索并没有找到)。请帮忙。

最佳答案

运行测试时,会在 C:\Windows\Cluster\Reports 中生成带有结果的 xml 文件

您可以使用此功能来检查有多少测试具有特定的结果状态

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 

关于powershell - 如何以对象格式获取测试集群输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50795958/

相关文章:

Redis 高可用性 - 如果主节点发生故障则增加同步

apache-spark - 如何配置 alb 在故障转移后指向新的主实例 (EMR)

java - 当集群中相应节点发生故障时,请求会发生什么情况

PowerShell:如何返回 Hyper-V 群集中的所有 VM

powershell - 从 PowerShell 打开并在 cmd 上运行命令

powershell - 将有序哈希表传递给函数

asp.net - Distributed Cache/Session 我应该转向哪里?

c# - 如何将挂载点的 Volume GUID 转换为实际路径?

powershell - 使用 powershell 将值传递到 ARM 模板参数

powershell - 将带有可变部分的消息从 PowerShell 输出到 TeamCity 构建日志