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

modifying the entire line whithin of text file vi powershell

$
0
0

hi friends

i need an script to select entire line within a text file & then replace the entire line with the line which i specify.

the scenario is:

in all of my clients, there is a text file which contains contents similar to following:

initial content
MyItem = 5
YourItem = 40
final content
two important notes:
the values in front of each item is not the same in my clients.
the initial content & also the final content is not the same in my clients.

for example in some clients, the value in front of MyItemt = 8 and in some others is 37 and so on...

i need to modify the values of the text file in all clients as following:
MyItem = 1
YourItem = 2
in fact i need an script to select anything in front of MyItem = and replace it with the digit 1
and also select anything in front of yourItem = and replace it with digit 2
i spent lots of time working on get-content with replace method & set-content & get-string & set-string but i was unable to achieve it. seems via these tools we can't get this need  :-(
thanks a a lot for any help
 

Viewing all articles
Browse latest Browse all 6937

Trending Articles