Skip to content

Instantly share code, notes, and snippets.

@rchaganti
Created January 30, 2020 13:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rchaganti/b4fc88f1615c6810b2c46b647ae4fe96 to your computer and use it in GitHub Desktop.
Save rchaganti/b4fc88f1615c6810b2c46b647ae4fe96 to your computer and use it in GitHub Desktop.
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