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

Status : 

 


1
0
Sign in
to vote
ID 831670 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 3/10/2014 2:19:29 PM
Access Restriction Public

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).
Sign in to post a comment.