$files = Get-ChildItem "K:Pathpath$file" -Filter *.bat | Select-object name foreach($file in $files) { (Get-Content "K:DFSITPDQ_DeployBatches$file") | ForEach-Object { $_ -replace "\path", "\newpath" } | Set-Content "K:Pathpath$file" }
It just errors out:
Get-Content : Cannot find path 'K:path@{Name=Vantage_Install.bat}' because it does not exist. At line:4 char:2 + (Get-Content "K:path$file") | ForEach-Object { $_ -replac ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (K:DFSITPDQ_D...ge_Install.bat}:String) [Get-Content], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
submitted by /u/DeathBoT
[link] [comments]
The post I want to grab lines of data in some bat files and replace them, can you help me? appeared first on How to Code .NET.