iainbrighton / PScribo

PowerShell documentation framework
MIT License
231 stars 35 forks source link

TOC Not working #77

Closed g-pearl closed 6 years ago

g-pearl commented 6 years ago

Pscribo version 0.7.23.119 Server 2012 Standard

$server_collection = $server_collection | Sort-Object hostname

$document = Document 'SQL_User' -verbose { documentOption -PageSize letter BlankLine -Count 20 Paragraph 'SQL User Review' -Style Title BlankLine -Count 20 PageBreak TOC -Name 'Table of Contents' PageBreak

foreach ($server in $server_collection)
    {
        write-host "Scanning $($server.hostname)"
        Paragraph -Style Heading1 $($server.hostname)
        $PSCred =$null
        $PSCred = New-Object System.Management.Automation.PSCredential($Server.Username,$(convertto-securestring -string $Server.Password))
        get-sqllogin -ServerInstance $server.hostname -Credential $PSCred | Select name,LoginType,Createdate,DateLastModified | table -Columns name,LoginType,Createdate,DateLastModified

    }
}

I get the following error:

The property 'Level' cannot be found on this object. Verify that the property exists. At line:96 char:21

If I comment out only the TOC -name line the code runs with no error

What am I doing wrong?

iainbrighton commented 6 years ago

Hi @g-pearl , I don't think you're doing anything wrong. I presume you get this error when exporting/generating the document with Export-Document? What format/plugins are you trying to convert to?

g-pearl commented 6 years ago

The export Command is: $document | Export-Document -Path $executingScriptDirectory -Format html,text

If doing just HTML I do not get the error. If doing just TEXT I do get the error. I also tried WORD and did not get the error. --- But when I opened the word document - I got a different error: "This document contains fields that may refer to other files. Do you want to update the fields in this document." (Yes/No) If I save then re-open the file the error does not come back up.

iainbrighton commented 6 years ago

Yep - there is a problem with the text TOC out, only on later PowerShell builds. I will publish a new version that fixes this and let you know.

As for the Word output, you will always see that warning if you use a TOC. Word has to repaginate the document to update the pages numbers in the POC. There's no way around this (unless you manually want to update the TOC?).

iainbrighton commented 6 years ago

@g-pearl I have published 0.7.24.122 to the PowerShell Gallery. Can you give that a go and let me know if it's fixed (or not) for you?