title: How do I do a conditional replace in PowerShell?
body: <p>Powershell Newbie looking for some help.</p>
  
  <p>I've got a powershell script which changes a priority value inside a text file to have a value of 50:</p>
  
  <pre><code>if ($line.contains("Priority") ) 
  {
     $LastComma = $line.LastIndexOf(",") +1
     $N = $line.Substring(0,$LastComma)
     $N = $N + "50"
     $lines[$counter] = $N
  
  } 
  </code></pre>
  
  <p>This works fine and does exactly what I want it to, but I now need to modify it so it changes the priority value to 45 if there is also the following line present:</p>
  
  <p><code>Provider = XYZ</code></p>
  
  <p>If this Provider value is not XYZ then all Priority values are set to 50 as before. Anyone have any advice on how can I achieve this?</p>
  
  <p>Thanks</p>