I read a xml file and want to replace three strings.
My Code:
foreach ($file in Get-ChildItem $files){
(Get-Content $file) | Foreach-Object {
$_ -replace 'TABLE_NAME="\$ZoneProdukt\$', ('TABLE_NAME="' + $ZONPRODLANG)`
-replace 'OPTION="Copy" ', '' `
-replace ('<JOB ','<JOB TIMETO="TEST" ') | ? {$_ -notlike "*TIMETO=`""}
} | Set-Content ($destination_folder + $file.name)
}
the last replace provides only the half of the result I expect.
If there are lines containing "JOB" and "TIMETO" they will not be displayed (because of Where-Object)
How to keep lines if the mentioned "TIMETO"-Attribute already exists?
examples:
source line in file (without "TIMETO"):
<JOB JOBISN="30" USER="testuser">
correct replace:
<JOB TIMETO="TEST" JOB JOBISN="30" USER="testuser">
....
....
source line in file (with "TIMETO"):
<JOB JOBISN="30" USER="testuser" TIMETO="0400">
replace -> this line will not be displayed !!
..
thanks in advance! br danijel