I’m working with DISA STIGs to harden Server 2012 R2. The STIGS use XML files to analyze how compliant the server is. I’m new to working with XML but I’m trying to create a psobject using that XML file and it mostly works. I’ve created the $xml variable as shown below:
[xml] $xml = Get-Content -Path stig.xml
The description for each rule in the STIG is a string with XML tags under $xml.benchmark.group.rule.description. I want to pull out those tags and be able to do .description.vulnDiscussion. The example XML is below:
I’ve tried using ConvertTo-Xml with no luck. It maintains the object as a string. I’ve also tried
and I get the error
Cannot convert value "System.Object" to type "System.Xml.XmlDocument". Error: "This document already has a 'DocumentElement' node."
I’m at a loss on how to convert that string to XML. Any ideas?