title: Powershell - Insert text after specific string in .xaml file
body: <p>I've written a number of batch files but I think batch falls short of my current task and I'm hoping Powershell can help me! The more difficult aspect of my task is to locate a particular string in a file and insert some text after the string, also on the same line and not disturbing the strings that fall on again on the same line afterwards. I found this code, but it has two pitfalls for my task...</p>
  
  <pre><code>$FileName = "C:\users\yef03111\desktop\main.xaml"
  $Pattern = "yiapcspvgcp:GraphicFileProperties.ScalingMode="
  $FileOriginal = Get-Content $FileName
  
  [String[]] $FileModified = @() 
  
  Foreach ($Line in $FileOriginal)
  {    
      $FileModified += $Line
  
      if ($Line -match "$Pattern") 
          {            
          $FileModified += "success!"       
      } 
  }
  Set-Content $FileName $FileModified
  </code></pre>
  
  <p>Firstly it places the text on the next line after the pattern, whereas I need it on the same line. Also the pattern I'm looking forward contains "" already which means that I've cut it short just for the time being to test. So pattern is actually...</p>
  
  <pre><code>#Not this
  $Pattern = "yiapcspvgcp:GraphicFileProperties.ScalingMode="
  #But this
  $Pattern = "yiapcspvgcp:GraphicFileProperties.ScalingMode="FixedRatio""
  </code></pre>
  
  <p>Please help a first timer out!!</p>