replace a few entries and save

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of turbo mcp turbo mcp 2 years, 1 month ago.

  • Author
    Posts
  • #19823
    Profile photo of turbo mcp
    turbo mcp
    Participant

    Hi
    I have a script that stops a service(noprob here)opens a file(noprob here) replaces a few entries using -replace(noprob here, I verified the variable for the file is changed)
    and then saves it.
    my problem is I don't see the actual file being saved with the changes:)
    I broke my foreach loop to only one server for easy troubleshooting.
    my replace lines and set-content look like this:
    $file= get-content "\\$server\c$\file.config"
    $file -replace 'entry1 ="1"$' ,'entry1="10" ' `
    -replace 'entry2 ="1"$' ,'entry1="10" ' `
    -replace 'entry3 ="1"$' ,'entry1="10" ' `
    |set-content "\\$server\c$\file.config"

    im sure its something small with the set-content I just cant figure it out:)
    any help would be appreciated
    Thanks

  • #19824
    Profile photo of turbo mcp
    turbo mcp
    Participant

    small mistake:)
    it works:)
    the file is so big that I was looking at the wrong enteries

You must be logged in to reply to this topic.