$wc = New-Object System.Net.WebClient
$DownloadString = $wc.DownloadString("http://www.example.com")
$HTML = New-Object -ComObject "HTMLFile"
$HTML.IHTMLDocument2_write($DownloadString)
Run Code Online (Sandbox Code Playgroud)
运行服务器脚本
Major Minor Build Revision
----- ----- ----- --------
5 1 14409 1005
Run Code Online (Sandbox Code Playgroud)
开发PC
Major Minor Build Revision
----- ----- ----- --------
5 1 15063 502
Run Code Online (Sandbox Code Playgroud)
我的Windows 10开发PC在上面的代码中运行良好.我想在我的Server 2008 R2 x64机器上运行它.我将其升级到PowerShell v5.我得到以下内容:
方法调用失败,因为[System .__ ComObject]不包含名为"IHTMLDocument2_write"的方法.
后来......
Unable to find type [mshtml.HTMLDocumentClass].
Run Code Online (Sandbox Code Playgroud) powershell internet-explorer ihtmldocument2 windows-server powershell-5.0