title: Using -f string format on get-content data in PowerShell
body: <p>I've got an XML template I put in a txt file. I'd like to import it to a variable and use "-f" to input my data into the string. Something like:</p>
  
  <pre><code>$XMLtmplt = get-content C:\XMLtemplate.txt
  $XML = "$XMLtmplt" -f $objID $pageTitle $otherData
  $OneNoteObject.UpdatePageContent($XML)
  </code></pre>
  
  <p>This works when the $XMLtmplt variable is set with a small string, but fails when I import a large string from a file. I'd rather not put a long XML string in my script; importing from a file is nice. My only work around thus far is to break up the data before and after the insertion point like:</p>
  
  <pre><code>$XML = "&lt;All the first data&gt;"
  $XML += $1stVariableToInsert
  $XML += "&lt;more XML stuff&gt;"
  $XML += $2ndVariableToInsert
  ...
  $OneNoteObject.UpdatePageContent($XML)
  </code></pre>
  
  <p>BTW, this is for building XML for the MS OneNote API, which I've found to be quite temperamental. The error codes are less than descriptive. A general "bad XML" doesn't help when you've got hundreds of lines of XML.</p>
  
  <p>Any ideas?</p>