Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Nested Get-content

$
0
0

hi gurus

As you can see on my previous post, I am new to PS , so go easy on me.

I need to find a way to nest get-content or a better way to accomplish the following:

I have a txt file with a bunch of machines in it, I need to go on every machine and read a file and make replace/change/edit content of the file and then save the file with the changes, so far I have the following

read the machine file

get-content $Machinefile

read the file that will be change

Get-content $filetoread

  No where I am having problem is putting this to get-content in a nest so every time I use the foreach to read a new machine ,then use the info to read and change the content of hat machine before I can move to the next machine

something like this

$machinefile="file.txt"

$filetoread="\location\location\"

get-content $machinefile | get-content $filetoread {foreach {$_ -Replace "source","change"}

so what I need is how to read the machine, then read the file on that machine,save changes to the on the machine and then move to the next machine on the machinefile.

I know it sounds confused , so I can answer any questions you might have.

 

Thanks a bunchhhhhhh

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles