Reading the Notepad file content and modifying them using powershell.

This topic contains 1 reply, has 1 voice, and was last updated by  Narayan Gupta 1 year, 5 months ago.

  • Author
    Posts
  • #37180

    Narayan Gupta
    Participant

    Hi Mates,

    I need help with below:

    1. One CSV file which has server name and its IP address.
    2. two conf files is placed on each server under c:\temp named as abc.conf and xyx.conf. 2nd line of the files contains IP address (xx.xxx.xx.xxx).
    3. I want powershell to read the csv, pick the IP address against the server name from csv.
    4.and Replace ip address in conf files on 2nd line only for each server with the picked IP in step3.
    5. I want to verify the changes using powershell also.

    Cheers,
    Narayan

  • #37181

    Narayan Gupta
    Participant

    (get-content c:\1.txt) | foreach-object {$_ -replace "abc", "xyz"} | set-content c:\1.txt

You must be logged in to reply to this topic.