title: Powershell - replace string in file
body: <p>I'm trying to edit the contents of a config file called prefs.cfg. It has two lines:</p>
  
  <pre><code>Server.Name "test"
  VoIP.Enabled "1"
  </code></pre>
  
  <p>I'm trying to get more comfortable with replacing string but I seem to keep messing up.</p>
  
  <p>I wrote something out, I would appreciate if someone could point in my script where I'm going wrong .</p>
  
  <pre><code>$prefs = Get-Content .\prefs.cfg
  
  $prefs | Select-String "Server.Name"
  
  $servername = Read-Host -Prompt "Enter Server Name"
  
  Write-Host $servername
  
  $prefs -replace $servername
  
  $prefs
  </code></pre>