Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Help needed doing a find/replace on a group of text files

$
0
0

In my experiences you have to write to the file every single time you replace a value. The only way to avoid doing this is to create a file stream object that allows you to open the file for writing.

I also have never had any problems with the ".Replace" method being case sensitive.

NewContent = $Content | % { $_.Replace('mdt-01', 'replacethis')  | Out-File $FilePath -Force -Append}

Using FileStream instead
http://blogs.technet.com/b/heyscriptingguy/archive/2005/02/08/how-can-i-find-and-replace-text-in-a-text-file.aspx

-VERN


Viewing all articles
Browse latest Browse all 13067

Trending Articles