[RESOLVED] Replacing a element in xml file
I am trying to write a script that will automate the locking down of IIS on our servers.
What I need to do is change the MaxConnections from 1000 to 100 while keeping all the other information intact. I just need an example of how to do this then i will be able to go from there.
Code:
<IIsWebServer Location ="/LM/W3SVC/1"
AppPoolId="DefaultAppPool"
DefaultDoc="Default.htm,Default.asp,index.htm,iisstart.htm"
MaxConnections="1000"
ServerBindings=":80:"
ServerComment="Default Web Site"
ServerSize="1"
>
</IIsWebServer>
There is another element call <IIsWebServer> but it doesnt contain the same information. So I dont want it to change the information in there....
Code:
<IIsWebServer Location ="/LM/W3SVC/Info/Templates/Public Web Site"
ServerComment="Allows all users to browse static and dynamic content."
>
</IIsWebServer>
If I am confusing let me know I will try and explain better.
Re: Replacing a element in xml file
See if this gets you started.
Code:
Option Explicit
Dim objDoc
Dim objNode
Dim objNodeList
Dim objAttrib
Dim strXmlFile
strXmlFile = "c:\iis.xml"
Set objDoc = CreateObject("Microsoft.XMLDOM")
objDoc.async = False
objDoc.Load strXmlFile
'Get all IIsWebServer nodes that have a MaxConnections attribute
Set objNodeList = objDoc.selectNodes("//IIsWebServer[@MaxConnections]")
'loop through the returned nodes
For Each objNode In objNodeList
'Get a copy of the attribute you want to change
Set objAttrib = objNode.Attributes.getNamedItem("MaxConnections")
'Set the value of the attribute
objAttrib.Text = "100"
Next
'Save the changes
objDoc.save strXmlFile
Re: Replacing a element in xml file
thanks for a great start!