'設置' name屬性值如何更改使用PowerShell腳本如何更改使用PowerShell腳本
XML
**
<ServiceConfiguration serviceName="test" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="Role1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="enableCounter" value="true" />
</ConfigurationSettings>
</Role>
<Role name="Role2">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="enableCounter" value="true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration >
'設置' name屬性值
**
我有這樣的腳本,它不工作
$serviceconfigpath= "D:\ServiceConfiguration.cscfg"
$doc = new-object System.Xml.XmlDocument
$doc.Load($serviceconfigpath)
$testValue= "test"
foreach($n in $doc.selectnodes("/ServiceConfiguration/Role"))
{
foreach($n in $doc.selectnode("/ServiceConfiguration/Role/ConfigurationSettings/Setting"))
{
switch($n.name)
{
"enableCounter" { $n.value = $testValue}
}
}
}
$doc.Save($serviceconfigpath)
你的XML被打破。缺少' ConfigurationSettings>'標籤。 – vonPryz 2011-04-11 08:26:43
現在正固定 – SRA 2011-04-11 08:49:07