If I put *.ps1 file in the same place as the files the files is change :-)
gciC:\loc*.txt-recurse|ForEach{
(
Get-Content$_|ForEach{$_-replace"Lars","Ole"})|Set-Content$_
}
But I put *.ps1 it somewhere else on the disk then says the get-content
Get-Content : Cannot find path 'C:\peter.txt' because it does not exist.
At C:\work\nr1.ps1:3 char:4
+ (Get-Content $_ | ForEach {$_ -replace "Lars", "Ole"}) | Set-Content $_
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\peter.txt:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
But it has found the file peter.txt ?
Why work Get-Content not the same place as gci