Hash Table Problem for EnhancedHtml2

This topic contains 0 replies, has 1 voice, and was last updated by  Des Davies 2 weeks, 3 days ago.

  • Author
  • #83512

    Des Davies

    Hi All,

    I'm updating a report to include some formatting based on the information in a field. The report is built using the EnhancedHtml2 module. Everything works great in the report until I start to replace items in the 'properties' with a hash table. However, it is very hit and miss. Some of the hash tables work, then one in a set will throw errors. The two pieces of code below show one that works (Firewall Info), and another that throws on error (Software Info).

    Final note, even though an error is thrown, the code works as planned.

    Any thoughts would be much appreciated.

    The error thrown is:
    ConvertTo-EnhancedHTMLFragment : Hashtable missing Name and/or Expression key
    At C:\Program Files\WindowsPowerShell\Modules\UWMTools\fn-Srv-Get-ServerBuildReview.ps1:178 char:46
    + ... tml_Software = $SoftwareInfo | ConvertTo-EnhancedHTMLFragment @params
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,ConvertTo-EnhancedHTMLFragment

            # Get the Firewall Info
                $params = @{'As'='Table';
                    'Properties'=@{n='Firewall Zone';e={$_.FirewallZone}},
                                 @{n='Firewall State';e={$_.FirewallState};css={if ($_.FirewallState -ne 'Disabled') { 'red' }}}
                } #Params for Info
                $html_firewall = $FirewallInfo | ConvertTo-EnhancedHTMLFragment @params
                $html_output.Add($html_firewall) | Out-Null
            # Get the Install Software Info
                $params = @{'As'='Table';
                    'PreContent'='INSTALLED SOFTWARE';
                                 @{n='Software';e={$_.Software};css={If ($_.Software -like 'VMWare Tools') { 'green' }}},
                } #Params for Software Info
                $html_Software = $SoftwareInfo | ConvertTo-EnhancedHTMLFragment @params
                $html_output.Add($html_software) | Out-Null

You must be logged in to reply to this topic.