我正在尝试从xml文件中提取一些信息,并根据需要更新/创建应用程序池.这是我正在阅读的xml:
<?xml version="1.0" encoding="utf-8"?>
<appPool name="MyAppPool">
<enable32BitAppOnWin64>true</enable32BitAppOnWin64>
<managedPipelineMode>Integrated</managedPipelineMode>
<managedRuntimeVersion>v4.0</managedRuntimeVersion>
<autoStart>true</autoStart>
</appPool>
Run Code Online (Sandbox Code Playgroud)
这是我正在尝试用它做的事情:
#read in the xml
$appPoolXml = [xml](Get-Content $file)
#get the name of the app pool
$name = $appPoolXml.appPool.name
#iterate over the nodes and update the app pool
$appPoolXml.appPool.ChildNodes | % {
#this is where the problem exists
set-itemproperty IIS:\AppPools\$name -name $_.Name -value $_.Value
}
Run Code Online (Sandbox Code Playgroud)
$_.Name返回节点的名称,(即enable32BitAppOnWin64)是正确的,但.Value属性不返回任何内容.如何提取我想要的数据?
Tre*_*van 24
更正的答案:
你想要$_.'#text'而不是$_.Value.
还要考虑这个,它使用对象InnerText上的属性System.Xml.XmlElement:
$ xml.appPool.ChildNodes | %{$ .Name; $ .InnerText};
| 归档时间: |
|
| 查看次数: |
27753 次 |
| 最近记录: |