Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Parses the XML validation report from Test-Cluster into a PowerShell Object
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[String]
$ValidationXmlPath
)
$xml = [xml](Get-Content -Path $ValidationXmlPath)
$channels = $xml.Report.Channel.Channel
$validationResultArray = New-Object -TypeName System.Collections.ArrayList
foreach ($channel in $channels)
{
if ($channel.Type -eq 'Summary')
{
$channelSummaryHash = [PSCustomObject]@{}
$summaryArray = New-Object -TypeName System.Collections.ArrayList
$channelId = $channel.id
$channelName = $channel.ChannelName.'#cdata-section'
foreach ($summaryChannel in $channels.Where({$_.SummaryChannel.Value.'#cdata-section' -eq $channelId}))
{
$channelTitle = $summaryChannel.Title.Value.'#cdata-section'
$channelResult = $summaryChannel.Result.Value.'#cdata-section'
$channelMessage = $summaryChannel.Message.'#cdata-section'
$summaryHash = [PSCustomObject] @{
Title = $channelTitle
Result = $channelResult
Message = $channelMessage
}
$null = $summaryArray.Add($summaryHash)
}
$channelSummaryHash | Add-Member -MemberType NoteProperty -Name Category -Value $channelName
$channelSummaryHash | Add-Member -MemberType NoteProperty -Name Results -Value $summaryArray
$null = $validationResultArray.Add($channelSummaryHash)
}
}
return $validationResultArray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.