Greetings all,
I'm trying to automate updating a configuration file at remote sites. I need to replace a string in a line, then insert a new line below it with another string.
So from this:
Sometext
SessionConfig=All \
Sometext
To this:
Sometext
SessionConfig=ICA \
Sessionreliability=YES \
Sometext
I've gone at this many different ways, each one failing. depending on the script I get something like this:
SessionConfig=All SessonConfig=YES \\
Or some other bad variation. Below is one attempt:
$replacement="SessionConfig=ICA \ `nSessionReliability=YES \"
(get-content wnos.ini) | foreach-object {$_ -replace "SessionConfig=All \",$replacement}|set-content wnos.ini
And another that just tries to add the new line:
(get-content $filename) |
foreach-object
{
$_
if ($_ -match "SessionConfig=ICA \")
{
"SessionReliability=YES \"
}
} |set-content $file
Any help would be appreciated, thanks.