从XML格式的IIS配置文件中获取我想要的数据时遇到问题。基本上,我需要获取一堆受限的IP地址以及webappname中的4个数字,即(Example / 3780)名称,然后导出到csv。
XML示例
<location path="Example/3780_Proxy_Test_01418277">
<system.webServer>
<security>
<ipSecurity>
<add ipAddress="10.10.199.20" allowed="true" />
<add ipAddress="10.10.81.80" subnetMask="255.255.255.240" allowed="true" />
<add ipAddress="10.10.199.16" subnetMask="255.255.255.240" allowed="true" />
<add ipAddress="10.10.163.150" allowed="true" />
<add ipAddress="10.10.163.151" allowed="true" />
</ipSecurity>
</security>
</system.webServer>
</location>
<location path="Example/3200_Proxy">
<system.webServer>
<security>
<ipSecurity>
</ipSecurity>
</security>
</system.webServer>
</location>
现在,我只停留在基础知识上,只是想让所有东西匹配
$path = "\path\to\whatever.xml"
$xpath = "/configuration/location/system.webserver/security/ipsecurity"
select-xml -path $path -xpath $xpath |select-object ipaddress