Need help converting PS object in to HTML

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Suresh krishnan Suresh krishnan 1 year, 2 months ago.

  • Author
  • #28795
    Profile photo of Suresh krishnan
    Suresh krishnan

    Dear All
    I need some help with my script. I have script that checks the hypervisor connection on each xendesktop sites and stores the information in to a ps object and then I am trying to convert that object in to html where i have problem .

    foreach ($Adminserver in $Adminservers){
    $hypervischeck = Get-BrokerHypervisorConnection -AdminAddress $Adminserver | Select-Object Name,State
    $HypervisorStatus  += New-Object psobject -Property @{Sitename = $Adminserver 
                                                  HypervisorName = $hypervischeck.Name
                                                  Status = $hypervischeck.State

    $hypervisorstuats contains the below details
    itename Status Hypervisroname
    ——– ——
    site1.exmaple.COM {On, On, On} {hyp1,hyp2,hyp3}
    site2.example.COM {On, Unavailable, On} {hyp4,hyp5}

    I get the below content in my html , the status object is showing as system.object[].

    Get-Content C:\temp\test.html

    Sitename Status HypervisorName

  • #28796
    Profile photo of Daniel Krebs
    Daniel Krebs

    Hi Suresh,

    Check out our free ebook "Creating HTML Reports In PowerShell" for ideas and may be the solution to your problem.


  • #28797
    Profile photo of Suresh krishnan
    Suresh krishnan

    Hi Daniel
    Thanks for the reference , Actually i am using his module and i get the error and i tried to check if i have the similar error in convertohtml .

    $HypervisorStatus | ConvertTo-EnhancedHTMLFragment -TableCssID XDTabke ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (@{Sitename=TYOR...ystem.Object[]}:PSObject) [ConvertTo-EnhancedHTMLFragment], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,ConvertTo-EnhancedHTMLFragment

    ConvertTo-EnhancedHTMLFragment : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its
    properties do not match any of the parameters that take pipeline input.

You must be logged in to reply to this topic.