find and replace from folders, subfolders

%3CLINGO-SUB%20id%3D%22lingo-sub-2197849%22%20slang%3D%22en-US%22%3Efind%20and%20replace%20from%20folders%2C%20subfolders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2197849%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Expert%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20find%20and%20replace%20from%20folders%20and%20subfolders%20files%20etc%20.presently%20i%20can%20do%20it%20to%20one%20folder%20only%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EGet-ChildItem%20D%3A%5CCheck%5C*.config%26nbsp%3B%20%7C%20Foreach%20%7B(Get-Content%20%24_)%20-replace%20'22.10.'%2C'SQL1'%7C%20Set-Content%20%24_%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Ehow%20i%20can%20i%20do%20it%20for%20multiple%20subfolders.i.e%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eafolder-afolder%2Cbfolder--cfolder%20so%20on%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EShree%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2197849%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

Hi Expert,

 

I am trying to find and replace from folders and subfolders files etc .presently i can do it to one folder only

 

Get-ChildItem D:\Check\*.config  | Foreach {(Get-Content $_) -replace '22.10.','SQL1'| Set-Content $_}

 

how i can i do it for multiple subfolders.i.e

afolder-afolder,bfolder--cfolder so on

 

Regards

Shree

1 Reply
add the -Recurse parameter for the Get-ChildItem

Get-ChildItem C:\Windows\*.config -Recurse