DevSupport
asked on
automated changes in xml files
In my enterprise I use pxexec to run scripts remotely on multiple servers. I have created several batch scripts to perform actions across multiple servers.
I would like to create a script which can run using psexec remotely across servers and perform bulk xml changes across multiple servers.
All the remote servers have xml files which I need to edit using an automated script.
Attached is an example of such an xml.
I want to change values like databaseName= or password= to a new value.
For a start, I would like to find a way to perform a change wherein I want to automatically change the password=efgh to a say new value password=lmno without loosing the consistency of the xml file.
I tried to do it using batch script but does not work as expected.
Any help would be much appreciated.
Best Regards
Amrith
I would like to create a script which can run using psexec remotely across servers and perform bulk xml changes across multiple servers.
All the remote servers have xml files which I need to edit using an automated script.
Attached is an example of such an xml.
I want to change values like databaseName= or password= to a new value.
For a start, I would like to find a way to perform a change wherein I want to automatically change the password=efgh to a say new value password=lmno without loosing the consistency of the xml file.
I tried to do it using batch script but does not work as expected.
Any help would be much appreciated.
Best Regards
Amrith
ASKER
Thank You for your quick response. Sorry I missed the attachment.Please find the xml attached.
context.xml
context.xml
ASKER
The PS version is 3.0
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Sir,
Thank You so much for building this script. Appreciate your quick response. I tried executing by passing a single file context.xml in this way, $XMLFile = Get-Content "C:\scripts\context.html"
But it doesn't seem to recognise it and gives the error "Found no property to set in the command line!".
Sorry I am a newbie to PS, please let me know which line should I add it.
Thank You!
Best Regards
Amrith
Thank You so much for building this script. Appreciate your quick response. I tried executing by passing a single file context.xml in this way, $XMLFile = Get-Content "C:\scripts\context.html"
But it doesn't seem to recognise it and gives the error "Found no property to set in the command line!".
Sorry I am a newbie to PS, please let me know which line should I add it.
Thank You!
Best Regards
Amrith
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You for your response, sorry was on vacation and did not get a chance to test it. I'll test it an let you know.
appreciate your details response and scripting efforts
Thanks
appreciate your details response and scripting efforts
Thanks
ASKER
Great Solution, still testing on pilot basis and I am sure it works well for Production!
And to bulk change files, I don't see the need for psexec, either. You can just connect through an admin share on the remote server and edit the file directly.
That said, you can change XML easily and, more important, without worrying about consistency, using Powershell.
But if you want further help with this, you need to provide the promised attachment (and ideally information on which platform the editing script would run, and its PS version - enter $Host in a PS console) ...