Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

Pfadangabe in einer Datei ersetzen

$
0
0

Hallo,

ich möchte gerne in einer Datei eine Pfadangabe suchen und durch eine andere ersetzen. Leider ist das Ergebnis noch nicht ganz so wie ich es mir wünsche. Kann mir jemand sagen was ich falsch mache?

$_NotesINI = "C:\Temp\Notes.ini"
$PathOld = 'C:\Lotus\Notes'
$PathOld = [regex]::escape($PathOld)
$PathNew = 'C:\Progra~2\Lotus\Notes'
$PathNew = [regex]::escape($PathNew)

(Get-Content $_NotesINI) | Foreach-Object {$_ -replace $PathOld, $PathNew} | Set-Content "C:\Temp\NotesNeu.ini"

Vorher sieht es so aus:

Directory=C:\Lotus\Notes\Data
NotesProgram=C:\Lotus\Notes\

---------------------------------------------------

Nachher

Directory=C:\\Progra~2\\Lotus\\Notes\Data
NotesProgram=C:\\Progra~2\\Lotus\\Notes\

---------------------------------------------------

Wieso sind plötzlich 2 Backslash an stellen wo nur einer sein sollte?

Liebe Grüße

Norbert


IT Berater


Viewing all articles
Browse latest Browse all 2314

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>