I am working on a script that will take laboratory testing results in the form of XML and fire off specific scripts on remote machines based upon testing results. The issue I am running into is that when I convert the XML to a PSObject the test results are being imported as a nested object and I can’t seem to get this to expand in an ideal way without losing the testing machine’s name in the process.
I have been searching for a solution for this for a couple of days now.
Example Data Properties Being imported from XML (Changed for Obscurity):
$.devices.device.Name: Laboratory1
$.devices.device.IPAddress: 192.168.0.101
$.devices.device.MACAddress: (MAC Address)
$.devices.device.LabTestResults: This is the nested object, containing around 1000 items all named “LabTestResults”, at the next level down, each “LabTestResults” has a unique ID, description, the test results (pass/fail/testing process failed), and the time the test was ran.
I’m importing the XML in this fashion:
[XML]$ReportListing = Get-Content 'C:\Example\Example.xml'
The issue is that I need to be able to iterate through the test results across multiple machines, find cases where “testing process failed”, and remotely kick off scripts that will fix known issues and restart the tests that failed (these scripts already exist), so I need to be able to return the name of the machine, and the IDs of tests that failed to provide as parameter arguments into the remediation scripts.
The idea output would be something like:
Name IPAddress MACAddress TestResult(ID) TestResult(OtherID) TestResult(3rdID)
Labratory1 192.168.0.101 (MAC Address) Pass Fail Testing Process Failed
so then I could theoretically do a “where-object” sort for finding cases that meet the criteria and grab the ID as well as the name.
Any help would be greatly appreciated.
Thanks,
Xeroize