我正在尝试从 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>
这是我正在尝试做的事情:
#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
}
$_.Name
返回正确的节点名称(即enable32BitAppOnWin64
),但该.Value
属性不返回任何内容。如何提取我想要的数据?