0

I am trying a simple replace script to replace text in a app.cofig file. But it just processed and do nothing:

$old = 'Z:\gene'
$new = 'z:\gene\scripts'
Get-ChildItem z:\gene\scripts\Test\App.config -Recurse | Where {$_ -IS [IO.FileInfo]} |
% {
(Get-Content $_.FullName) -replace $old,$new | Set-Content $_.FullName
Write-Host "Processed: " + $_.FullName
}

Any Idea what I am doing wrong. As same script works fine for .txt file Thanks

1 Answer 1

1

App.config is xml formatted but it's a text file as well, it should work the same. My guess is that you have a different values that your working on and they are not hitting. If you rename the file to app.txt does it work ? You might also consider using nant xmlpoke if you are running from nant script.

Sign up to request clarification or add additional context in comments.

1 Comment

yes checked..Seems it is not scripting the path drives while replacing. If you use simple text instead of z: then it works. Any idea how to replace the full path as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.