This PowerShell Module has multiple functionalities, but one of the signature features of this module is the ability to parse Security logs on Domain Controllers providing easy to use access to AD Events.
MIT License
705
stars
70
forks
source link
Colors & Styles not working with accents and other non-ascii characters #80
We can see the Replace function is called on the Body variable which contains the HTML body.
Accents (and others non-ascii characters) are usually html-encoded to avoid rendering issue.
We can quickly see this is indeed the case here when looking at the raw HTML output:
The solution would be to html-encode the color/style values before trying to replace them in the HTML body.
Workaround
For a simple workaround, simply drop these two lines before calling Start-ADReporting (assuming the formatting options are in the $FormattingParameters variable):
It simply iterates over all colors/styles values and html-encode them.
(Note that I left the HtmlDecode in case somebody run these lines multiple time)
With that, the colors and styles are now working 😸
Tested on the Legacy script (V1). I didn't test on the V2 version.
For a workaround, see below.
If a formatting value (be it for color or style) is using accent or other non-ascii characters, then the color or style won't be applied.
Since event log are localized, accented characters can appeared in the report (French in our case).
Given a formatting option below:
It does not highlight the word:
The issue is not linked to the file encoding, as UTF8-BOM is used and the accent is correctly encoded as we can see in the log:
The issue is related to the way the replace function is actually called: https://github.com/EvotecIT/PSWinReporting/blob/36089a85e19c8758102e4e3e9bc81737b1760238/Private/PSWinReportingEmails.ps1#L62-L64
We can see the
Replace
function is called on theBody
variable which contains the HTML body.Accents (and others non-ascii characters) are usually html-encoded to avoid rendering issue. We can quickly see this is indeed the case here when looking at the raw HTML output:
The solution would be to html-encode the color/style values before trying to replace them in the HTML body.
Workaround
For a simple workaround, simply drop these two lines before calling
Start-ADReporting
(assuming the formatting options are in the$FormattingParameters
variable):It simply iterates over all colors/styles values and html-encode them. (Note that I left the HtmlDecode in case somebody run these lines multiple time)
With that, the colors and styles are now working 😸