I'm trying to modify the web.config using PowerShell.
So far, I'm able to replace the Connection String using:
Set-WebConfigurationProperty -pspath "IIS:\Sites\$Name\WS" -filter "connectionStrings/add[@name='Product.Core.WebServices.Properties.Settings.DirectoryConnectionString']" -name "connectionString" -value "Server=SERVERNAME\INSTANCE1;Database=ProductDirectory.$Name;Trusted_Connection=True;" this works OK.
Now, I want to change something in the applicationSettings part of the web.config. The Part looks like:
<applicationSettings> <Product.Core.WebServices.Properties.Settings> <setting name="LogLevel" serializeAs="String"> <value>Info</value> </setting> <setting name="LogDirectory" serializeAs="String"> <value>D:\temp</value> </setting> <setting name="LogSpecialTroubleshoot" serializeAs="String"> <value>False</value> </setting> <setting name="LogSqlQueries" serializeAs="String"> <value>False</value> </setting> <setting name="LogPerformance" serializeAs="String"> <value>False</value> </setting> <setting name="LogXmlInput" serializeAs="String"> <value>False</value> </setting> <setting name="LogXmlInputSeperate" serializeAs="String"> <value>False</value> </setting> <setting name="EnableCatchAllLogging" serializeAs="String"> <value>True</value> </setting> <setting name="DirectoryDatabaseName" serializeAs="String"> <value>ProductDirectory</value> </setting> </Product.Core.WebServices.Properties.Settings> </applicationSettings> I would like to change the "DirectoryDatabaseName" node.
Using:
Set-WebConfigurationProperty -pspath "IIS:\Sites\$Name\WS" -filter "applicationSettings" -name "test" -value "ProductDirectory.$Name" I can change the "root" node (applicationSettings) and add an attribute with name "test" to it. However, if I'm trying to go "deeper" into the structure, I get the following Error:
WARNING: Target configuration object 'applicationSettings/Product.Core.WebServices.Properties.Settings/setting[@name='DirectoryDatabaseName'] is not found a t path 'MACHINE/WEBROOT/APPHOST/TestM/WS'. I'm using the following PS for that:
Set-WebConfigurationProperty -pspath "IIS:\Sites\$Name\WS" -filter "applicationSettings/Product.Core.WebServices.Properties.Settings/setting[@name='DirectoryDatabaseName']" -name "test" -value "ProductDirectory.$Name" Not even this works (same error):
Set-WebConfigurationProperty -pspath "IIS:\Sites\$Name\WS" -filter "applicationSettings/Product.Core.WebServices.Properties.Settings" -name "test" -value "ProductDirectory.$Name" So somehow it stops working "one level below" applicationSettings
Also, how would the syntax be to change the text between <value> and </value>?