title: Use PowerShell to save Word document as HTML with encoding
body: <p>Using the following PowerShell script, I am converting a directory of Word documents to HTML.</p>
  
  <pre><code>$wdTypes = Add-Type -AssemblyName 'Microsoft.Office.Interop.Word' -Passthru
  [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.Office.Interop.Word.WdSaveFormat')
  $docSrc = "C:\Users\Me\Desktop\TestWordDocs"
  $htmlOutputPath = "C:\Users\Me\Desktop\TestHTMLDocs"
  $srcFiles = Get-ChildItem $docSrc -filter "*.doc"
  $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML");
  $wordApp = new-object -comobject word.application
  $wordApp.Visible = $false
  
  function saveashtml {
    $openDoc = $wordApp.documents.open($doc.FullName);
    $openDoc.saveas([ref]"$htmlOutputPath\$doc.fullname.html", [ref]$saveFormat);
    $openDoc.close();
  }
  
  ForEach ($doc in $srcFiles) {
    Write-Host "Converting to html :" $doc.FullName
    saveashtml
    $doc = $null
  }
  
  $wordApp.quit();
  </code></pre>
  
  <p>This successfully converts the file but not in UTF-8 format as seen in the <code>meta</code> tag.</p>
  
  <pre><code>&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;
  </code></pre>
  
  <p>Special characters are displayed as � in the HTML file.</p>
  
  <p>How can I fix this?</p>