none
ConvertTo-Html and Out-File cmdlets

    Domanda

  • Hi

    In PowerShell 2.0 console, I wrote:

    PS C:\Users\test\Documents\PowerShell> Get-Service | ForEach-Object {`
    >>                                                                   If ($_.Status -eq "Stopped") {Write-Host $_.Name $_.Status -ForegroundColor Red}
    >>                                                                   else {Write-Host $_.Name $_.Status -ForegroundColor Green}
    >>                                                                  } | ConvertTo-Html | Out-File .\Test.html

    I noticed that the output is displayed on the screen instead of being stored in the Test.html file. In fact, in the Test.html file, I find only:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>HTML TABLE</title>
    </head><body>
    <table>
    </table>
    </body></html>

    Why?

    Thanks

    Bye

    • Modificato balubeto mercoledì 27 giugno 2012 07:04
    mercoledì 27 giugno 2012 07:03

Risposte