Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created January 10, 2018 17:01
Show Gist options
  • Save jcefoli/607dd45f1c919c9c8633672b143dc4bd to your computer and use it in GitHub Desktop.
Save jcefoli/607dd45f1c919c9c8633672b143dc4bd to your computer and use it in GitHub Desktop.
Powershell Find/Replace: Recursively replace text in all *.config files in a directory using .NET
$configFiles = Get-ChildItem C:\YourDirectory *.config -Recurse
foreach ($file in $configFiles)
{
$content = [System.IO.File]::ReadAllText($file.FullName).Replace('foo','bar')
[System.IO.File]::WriteAllText($file.FullName, $content)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment