Home Dashboard Directory Help
Search

Confusing error message on Start-Transcript if $TRANSCRIPT is not a string by Roman Kuzmin


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 831670
Opened: 3/10/2014 2:19:29 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

Suppose a user defines the variable $TRANSCRIPT which is not a string. Perhaps a user even does not think of transcribing but just uses this variable for something else.

PS> $TRANSCRIPT = 1

Then a user starts transcribing by Start-Transcript and gets this error message:

PS> Start-Transcript
Start-Transcript : Unable to cast object of type 'System.Int32' to type 'System.String'.
At line:1 char:1
+ Start-Transcript
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo         : NotSpecified: (:) [Start-Transcript], InvalidCastException
    + FullyQualifiedErrorId : System.InvalidCastException,Microsoft.PowerShell.Commands.StartTranscriptCommand

The error message should explain what happens. Namely, by the convention, the cmdlet uses the variable $TRANSCRIPT if it is defined. This has to be mentioned in the error message.

P.S. It is about PS v3.0 (perhaps it is fixed in v4.0, I cannot check this).
Details
Sign in to post a comment.
Sign in to post a workaround.