1
當前要使用PowerShell腳本替換XML文件的from,to和subject屬性。使用PowerShell替換XML屬性
<configuration>
<configSections>
</configSections>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="SqlServer" />
<errorMail from="[email protected]" to="[email protected]" cc="" subject="Error email title"/>
<errorFilter>
<test>
</test>
</errorFilter>
</elmah>
我曾嘗試以下foreach循環,但這似乎沒有更新的屬性:
$xmlDoc = [XML](Get-Content "$path\Web.config")
foreach ($item in $xmlDoc.configuration.elmah.errorMail){
{$item.from = '[email protected]'}
{$item.to = '[email protected]'}
{$item.subject = 'test3'}
}
$xmlDoc.Save("$path\Web.config")
任何人使用此腳本幫助嗎?