Skip to content

Style Highlight Question #97

@g-pearl

Description

@g-pearl

I am trying to work on a configuration report and I want to Highlight areas that are incorrect.

I have everything working like I want but when I apply a style it highlights the entire line but I would like it to highlight only the provided text.

Is there a WholeLine (True/False) parameter that I missed or is this the designed result. I could see both options being useful.

Code is as follows:

Import-Module PScribo

Document 'PScribo Example' {
        Style -Name 'Error' -Color White -BackgroundColor Firebrick -Bold

        $mailgood = "mailhub=10.10.10.20"
        $mailbad = "mailhub=localhost"

        $OverrideGood = "FromLineOverride=YES"
        $Overridebad = "FromLineOverride=NO"

        $DNSGood = "8.8.8.8"
        $DNSBad = $null

        if ($mailgood -like "*hub=10.10*")
            {
                Paragraph -Style normal $mailgood
            }
        else
            {
                Paragraph -Style Error $mailgood
            }
        if ($mailbad -like "*hub=10.10*")
            {
                Paragraph -Style normal $mailbad
            }
        else
            {
                Paragraph -Style Error $mailbad
            }

        if (![string]::IsNullOrWhiteSpace($DNSGood))
            {
                Paragraph -Style normal $DNSGood
            }
        else
            {
                Paragraph -Style Error $DNSGood
            }
        if (![string]::IsNullOrWhiteSpace($DNSBad))
            {
                Paragraph -Style normal $DNSBad
            }
        else
            {
                Paragraph -Style Error "DNS Undefined"
            }

    } | Export-Document -Path ~\Desktop -Format Word -Verbose

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions