Custom PSobject HTML output

Welcome Forums General PowerShell Q&A Custom PSobject HTML output

This topic contains 1 reply, has 2 voices, and was last updated by

7 months, 1 week ago.

  • Author
  • #111877

    Topics: 19
    Replies: 23
    Points: 94
    Rank: Member

    Hello Team,

    My PS Custom object concept is not very clear. So need your help to understand and fix the issue. I want to create a system report which contains multiple information. Following is an example code. I am holding multiple objects' output in a custom object and trying to convert it in HTML, but the result is not showing as I am expecting. I am expecting what I see in the console by enumerating each property should be in HTML file like that. I am definitely sure that I have some conceptual mistakes. But need your support to rectify those.

    $hstbl = @{}
    $hstbl.Add('RunningSrvs',(gsv -name [a-b]*|select DisplayName, Status |ft -AutoSize))
    $hstbl.Add('RunningProcs',(gps -name [a-f]*|? cpu -gt $null |select Name, CPU |ft -AutoSize))
    $obj = New-Object PSCustomObject -Property $hstbl

    I tried for HTML output,

    $obj.RunningSrvs|ConvertTo-Html | Out-File C:\test.html
    $obj.RunningProcs|ConvertTo-Html | Out-File C:\test.html -append

    By doing this, getting some kind of wired HTML output.

    Eagerly waiting for your input, please help...



  • #111895

    Topics: 8
    Replies: 350
    Points: 316
    Helping Hand
    Rank: Contributor
    Get-Service -name [a-b]* | select DisplayName, Status | ConvertTo-Html | Out-File .\Report1.html
    '(p)(hr)(p)' | Out-File .\Report1.html -Append # replace brackets with html tag characters that won't show here
    Get-Process -name [a-f]* | where cpu | select Name, CPU | ConvertTo-Html | Out-File .\Report1.html -Append
    & .\Report1.html

The topic ‘Custom PSobject HTML output’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort