Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hgirish/5188192014b9494900c23822f9adeac1 to your computer and use it in GitHub Desktop.
Save hgirish/5188192014b9494900c23822f9adeac1 to your computer and use it in GitHub Desktop.
$files = Get-ChildItem "app*.config" -Recurse
$find = 'some-string-to-find'
$replace = 'some-string-to-replace-with'
Get-ChildItem $files -Recurse |
select -ExpandProperty fullname |
foreach {
If(Select-String -Path $_ -SimpleMatch $find -quiet){
(Get-Content $_) |
ForEach-Object {$_ -replace $find, $replace } |
Set-Content $_
write-host "File Changed : " $_
}
}
@L258
Copy link

L258 commented Feb 13, 2022

that is great, save my 10 times time. Thank you HGIRISH!

@guillaume130679
Copy link

Same here, very useful peace of code, thanks!

@hgirish
Copy link
Author

hgirish commented Aug 2, 2022

Same here, very useful peace of code, thanks!
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment