I have a folder with multiple files. I want to read each file and replace with whatever the user passes to the application (a parameter). After the content of the file is replaced, I want to save the file in a new folder.
This is what I have so far:
gci C:\Users\Person\Documents\Test1\*.bat -recurse | ForEach {
(Get-Content $_ | ForEach {$_ -replace "<client_instance>", "ClientName"}) | Set-Content $_
}
My first question is, is this correct and secondly, how do I change "Set-Content" so that it saves the files in a different folder?
I want to use variables for the source and destination:
$sourePath
$destinationPath
I'm new to PowerShell so any help would be greatly appreciated. Thanks.