powershell - 如何以对象格式获取测试集群输出?
问题描述
该命令Test-Cluster
将输出作为 xml 和 htm 文件。
$v = test-cluster -Node w16-sqlcA,w16-sqlcB -Include "Storage" -Force -Disk $csv -Verbose
似乎获得详细结果的唯一方法是解析 xml。我必须获取活动的名称及其结果,就好像它显示在下面的 htm 文件中一样。
有没有内置的方法来获取它?(或者已经为测试集群结果编写了一个解析器?我搜索并没有找到)。请帮忙。
解决方案
运行测试时,会在 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
推荐阅读
- c# - C# - 生成最多 3 位数的随机用户名有时会出现 4 位数
- elasticsearch - 如何对包含空格的属性名称进行弹性搜索聚合
- node.js - 如何在源程序终止时捕获整个程序管道输出?
- python - Python - dir(list) -- __functions__ 它们是什么?
- c# - 在 mvc 中将 C# 字符串与 jquery 进行比较
- javascript - 在 React 中以列表格式输出数组
- android - TextView 更改后 ImageButton 更改位置
- qt - 在 CMake 中链接到 Qt --> 无法链接到 QML/QtQuick 函数
- sql-server - xp_instance_regread 程序不断自动执行
- php - 无法通过 php 在 mongodb 中查询 ISODate