Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Replace Everything After "=" In File BUT Only For Specific Variable In File

$
0
0

I have a file that contains the following:

baseHostname=record.site.com
username=user
password=passwordWhat I am attempting to do is replace everything to the right of the "=" ONLY IN "baseHostname=record.site.com"

I thought I was close with: (get-content $sitepath) -match 'baseHostname' | foreach-object {$_ -replace '/=.+', 'record.site.com'} | set-content $sitepath

Unfortunately what that ended up doing is replacing EVERY item to the right of the = including the equal sign.

Thoughts?

-P


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>