PowerShell 将[xml]
文档转换为深层/复杂对象。我下载了一个 STIG 文档并像这样加载它
PS> $xml = [xml](Get-Content .\U_A10_Networks_ADC_ALG_STIG_V1R1_Manual-xccdf.xml)
现在,您可以评估对象
PS> $xml
xml xml-stylesheet Benchmark
--- -------------- ---------
version="1.0" encoding="utf-8" type='text/xsl' href='STIG_unclass.xsl' Benchmark
或者遍历它的属性。
PS> $xml.Benchmark
dsig : http://www.w3.org/2000/09/xmldsig#
xsi : http://www.w3.org/2001/XMLSchema-instance
cpe : http://cpe.mitre.org/language/2.0
xhtml : http://www.w3.org/1999/xhtml
dc : http://purl.org/dc/elements/1.1/
id : A10_Networks_ADC_ALG_STIG
lang : en
schemaLocation : http://checklists.nist.gov/xccdf/1.1 http://nvd.nist.gov/schema/xccdf-1.1.4.xsd
http://cpe.mitre.org/dictionary/2.0 http://cpe.mitre.org/files/cpe-dictionary_2.1.xsd
xmlns : http://checklists.nist.gov/xccdf/1.1
status : status
title : A10 Networks ADC ALG Security Technical Implementation Guide
description : This Security Technical Implementation Guide is published as a tool to improve the security of
Department of Defense (DoD) information systems. The requirements are derived from the National
Institute of Standards and Technology (NIST) 800-53 and related documents. Comments or proposed
revisions to this document should be sent via e-mail to the following address: disa.stig_spt@mail.mil.
notice : notice
reference : reference
plain-text : plain-text
version : 1
Profile : {Profile, Profile, Profile, Profile...}
Group : {Group, Group, Group, Group...}
看起来大部分信息都在这条路上:
$xml.Benchmark.Group.Rule