replace a few entries and save

Welcome Forums General PowerShell Q&A replace a few entries and save

This topic contains 1 reply, has 1 voice, and was last updated by

4 years, 4 months ago.

  • Author
  • #19823

    Points: 1
    Rank: Member

    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

  • #19824

    Points: 1
    Rank: Member

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

The topic ‘replace a few entries and save’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort