Skip to content

Problems with GroupHeaders #11

@GitHubBJW

Description

@GitHubBJW

I created a table in a report as follows:
$rpt += Get-HTMLContentTable -ArrayofObjects ($ArrItems | Select-Object EventId, Time, WinLog, EntryType, Source, Message) -GroupBy EventId
The grouping worked fine when the report was simple, but when one of the items, specifically the "Message" property was very large and complex the report ended up with extra lines in the report with the message property in the upper left hand corner of each table. I debugged the PSM1 file and found that the group header is generated as an HTML fragment followed by another line which tries to use a series "-replace" operators to remove non-header related information. When those "replaces" don't find a match, you end up with junk in your header. Specifically, I believe in my case this particular -Replace statement wasn't matching for whatever reason:
-replace ".+?"
I modified the following lines in the .psm1 file (Lines 958 and 959):
$GroupHeader = $ArrayOfObjects | ConvertTo-Html -Fragment
$GroupHeader = $GroupHeader -replace '', "" -replace '', "" -replace '', "" -replace '

', "" -replace '
', "" -replace ".+?" -replace "", ""
Modified:
ForEach ($Item in $Groupings) {$GroupHeader = $GroupHeader + "$Item"}
$GroupHeader="$GroupHeader"
This corrected my issue. Perhaps this change will be more robust since it doesn't rely upon string matches, but generates the header information from the list of distinct list of Groupings.
Thank you,
Brian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions