title: Parsing local HTML file using New-Object -ComObject "HTMLFile" broken?
body: <p>I have been running a password expiration script for the pass 6 months without any issue. The script will read in a static html file and change around some of the content in memory and then an html email will be sent to all users who have expiring passwords.</p>
  
  <p>The script seems to have broke in the past week or so. Upon further investigation I've narrowed down the errors to the section where Powershell is supposed to create a new ComObject and write that HTML file to the ComObject. </p>
  
  <p>I now get the error :</p>
  
  <pre><code>No coercion operator is defined between types 'System.Array' and 'System.String'
  At line:1 char:1
  + $html.write($source);
  + ~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : OperationStopped: (:) [], InvalidOperationException
      + FullyQualifiedErrorId : System.InvalidOperationException
  </code></pre>
  
  <p>The above error happens when I run below lines of code :</p>
  
  <pre><code>$html = New-Object -ComObject "HTMLFile"
  $src = Get-Content -path "./passwordreminder.html" -Raw
  $html.write($src)
  </code></pre>
  
  <p>When I invoke the <code>write()</code> method I get the error.</p>
  
  <p>Since its been working fine for the last 6 months, the only thing that I can think of that has changed is my version of powershell. I believe when I started running this script I was using Powershell v4.0, but after Windows Updates I guess Powershell is now at v5.0. See below :</p>
  
  <pre><code>Name                           Value
  ----                           -----
  PSVersion                      5.0.10105.0
  WSManStackVersion              3.0
  SerializationVersion           1.1.0.1
  CLRVersion                     4.0.30319.34209
  BuildVersion                   10.0.10105.0
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
  PSRemotingProtocolVersion      2.3
  </code></pre>
  
  <p>The script is running on Windows Server 2012 R2 OS.</p>
  
  <p>Anyone have any ideas?</p>
  
  <p>I've seen some suggestions in other questions calling to use the <code>IHTMLDocument2_write()</code> method on the ComObject, but this method doesn't exist when I try to invoke it. </p>
  
  <p><strong>Update :</strong></p>
  
  <p>I was able to confirm that this is <strong>INDEED BROKEN</strong> in my version of Powershell.</p>
  
  <p>I was just able to test the same code on a different server with the same OS but below version of Powershell :</p>
  
  <pre><code>Name                           Value
  ----                           -----
  PSVersion                      4.0
  WSManStackVersion              3.0
  SerializationVersion           1.1.0.1
  CLRVersion                     4.0.30319.34014
  BuildVersion                   6.3.9600.17090
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
  PSRemotingProtocolVersion      2.2
  </code></pre>
  
  <p>And the code works as expected.</p>
  
  <p>Anybody know what can be used in this new version of Powershell?</p>