title: Replace command in powershell is deleting the whole content
body: <p>I am new to powershell. I create a powershell script which need to search a string in the path provided in parameters and replace that string. But actually it is replacing entire file content with new string.</p>
  
  <p>I am using Powershell in Windows 10 OS.
  Code:</p>
  
  <pre><code>param(
          [Parameter(Mandatory=$true, ParameterSetName="Path", Position=0,HelpMessage='Data folder Path')]
          [string] $Path,
  
  
          [Parameter(Mandatory=$true, HelpMessage='Input the string to be replaced')]
          [string] $Input,
  
          [Parameter(Mandatory=$true,HelpMessage='Input the new string that need to be replaced')]
          [string] $Replace
  
  )
  
  $a = Test-Path $Path
  IF ($a -eq $True) {Write-Host "Path Exists"} ELSE {Write-Host "Path Doesnot exits"}
  $configFiles = Get-ChildItem -Path $Path -include *.pro, *.rux -recurse
  $Append = join-path -path $path \*
  $b = test-path $Append -include *.pro, *.rux
  If($b -eq $True) {
    foreach ($file in $configFiles)
    {
      (Get-Content $file.PSPath) |
      Foreach-Object { $_ -replace [regex]::Escape($Input), $Replace } |
      Set-Content $file.PSPath
    } 
  $wshell = New-Object -ComObject Wscript.Shell
  $wshell.Popup("Operation Completed",0,"Done",0x0)
  }
  </code></pre>