-
-
Save KurtDeGreeff/f5efc3e7efe8a7697c1d36a44f0d7c39 to your computer and use it in GitHub Desktop.
Parses the XML validation report from Test-Cluster into a PowerShell Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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