Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (Get-Content c:temptest.txt).replace('[MYID]', 'MyValue') | Set-Content c:temptest.txt
- (Get-Content c:temptest.txt) -replace '[MYID]', 'MyValue' | Set-Content c:temptest.txt
- (Get-Content file.txt) |
- Foreach-Object {$_ -replace '[MYID]','MyValue'} |
- Out-File file.txt
- $content = [System.IO.File]::ReadAllText("c:bla.txt").Replace("[MYID]","MyValue")
- [System.IO.File]::WriteAllText("c:bla.txt", $content)
- $path = "C:testFile.txt"
- $word = "searchword"
- $replacement = "ReplacementText"
- $text = get-content $path
- $newText = $text -replace $word,$replacement
- $newText > $path
- get-content $pathToFile | % { $_ -replace $stringToReplace, $replaceWith } | set-content $pathToFile
- try
- {
- $reader = [System.IO.StreamReader] $pathToFile
- $data = $reader.ReadToEnd()
- $reader.close()
- }
- finally
- {
- if ($reader -ne $null)
- {
- $reader.dispose()
- }
- }
- $data = $data -replace $stringToReplace, $replaceWith
- try
- {
- $writer = [System.IO.StreamWriter] $pathToFile
- $writer.write($data)
- $writer.close()
- }
- finally
- {
- if ($writer -ne $null)
- {
- $writer.dispose()
- }
- }
- Get-ChildItem 'C:yourfile*.xml' -Recurse | ForEach {
- (Get-Content $_ | ForEach { $_ -replace '[MYID]', 'MyValue' }) |
- Set-Content $_
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement