Skip to content Skip to sidebar Skip to footer

Print Automatically Html File With Powershell

I want to print an html file to the default printer with powershell. So lets say I have the file c:\test.html with the text:

hello world&l

Solution 1:

get-content c:\test.html  | out-printer

Print to default printer.

Edit:

if you need print rendered htlm page:

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

Edit after comments:

I can run this in a testprint.ps1 file:

$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()

Post a Comment for "Print Automatically Html File With Powershell"