使用PowerShell自动打印html文件

Art*_*lho 2 html printing powershell

我想用PowerShell将html文件打印到默认打印机.所以我要说文件c:\ test.html包含文字:

<html>
<p> hello <b>world</b></p>
<html>
Run Code Online (Sandbox Code Playgroud)

我怎么能将test.html打印到默认打印机?

先感谢您.

CB.*_*CB. 5

get-content c:\test.html  | out-printer
Run Code Online (Sandbox Code Playgroud)

打印到默认打印机.

编辑:

如果你需要打印渲染的htlm页面:

$ie = new-object -com "InternetExplorer.Application"
$ie.Navigate("c:\test.html")
$ie.ExecWB(6,2)
Run Code Online (Sandbox Code Playgroud)

评论后编辑:

我可以在testprint.ps1文件中运行它:

$ie = new-object -com "InternetExplorer.Application"
$ie.Navigate("c:\test.html")
while ( $ie.busy ) { Start-Sleep -second 3 }
$ie.ExecWB(6,2)
while ( $ie.busy ) { Start-Sleep -second 3 }
$ie.quit()
Run Code Online (Sandbox Code Playgroud)