PowerShell 3 AND 4 (malformed) signed script blocks breaks the parser - by Joel 'Jaykul' Bennett

Status : 


Sign in
to vote
ID 807507 Comments
Status Active Workarounds
Type Bug Repros 1
Opened 11/1/2013 1:13:11 PM
Access Restriction Public


In PowerShell 3, if there is a signed script block (or script, or localized data file) which is imported (invoked interactively, or parsed using Import-LocalizedData), ALL localized data files (or interactive commands) which are imported/executed after that must be shorter than the previous signed one or they will fail to parse with a TokenAfterEndOfValidScriptText error:

Executable script code found in signature block.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TokenAfterEndOfValidScriptText

NOTE: this bug affects Import-LocalizedData *AND* the "data" keyword in PowerShell scripts.

In PowerShell 4, the bug only emerges when the signature block is cut off (say, if someone accidentally deletes the last line of a signature).

Reproduction steps below apply to PS3 or PS4 (because I don't put a full signature in the reproduction).

This does not affect PS2.
Sign in to post a comment.