Support Forums

PrimalScript 2015 failed to show error line number with PV2

Support for all customers who have purchased a PrimalScript product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
User avatar
clum09
Posts: 114
Joined: Thu Apr 24, 2008 9:11 am

PrimalScript 2015 failed to show error line number with PV2

Postby clum09 » Fri Oct 02, 2015 6:36 am

Hello,

I try to open a PowerShell script in PrimalScript 2015 with a PowerShell V2 mode - I select the v2 icon on top of the Platform menu bar.

The code is shown below:

Code: Select all

[CmdletBinding()]
   Param([Parameter(Mandatory=$true,
      ValueFromPipeline=$true,
      ValueFromPipelinebyPropertyName=$true)]
      [object]$object
   )
   BEGIN {}
   PROCESS {
      
   }
   END {}
}


Then I press on the Run button to test the script, but I get from the Output screen is the error below - there is no indication what line of the code that this error was generated from.

ERROR: <position> : Missing ] at end of type token.
ERROR: + CategoryInfo : ParserError: (Parameter(Mandatory=$true,:String) [], ParseException
ERROR: + FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfType
ERROR:

Execution time: 00:00:02

However, when I select the PowerShell V4 mode - I select the v4 icon on top of the Platform menu bar, I get the error below.

ERROR: At C:\Scriptings\PowerShell\Test.ps1:491 char:1
ERROR: + [CmdletBinding()]
ERROR: + ~~~~~~~~~~~~~~~~~
ERROR: Unexpected attribute 'CmdletBinding'.
ERROR:
ERROR: At C:\Scriptings\PowerShell\Test.ps1:492 char:2
ERROR: + Param([Parameter(Mandatory=$true,
ERROR: + ~~~~~
ERROR: Unexpected token 'Param' in expression or statement.
ERROR:
ERROR: At C:\Scriptings\PowerShell\Test.ps1:502 char:1
ERROR: + }
ERROR: + ~
ERROR: Unexpected token '}' in expression or statement.
ERROR:
ERROR:
ERROR: + CategoryInfo : ParserError: (:) [], ParseException
ERROR: + FullyQualifiedErrorId : UnexpectedAttribute
ERROR:

Execution time: 00:00:02

How can I set up PrimalScript 2015 so that it can it can generate the error ouput for both PowerShell V2 and PowerShell V4 editing modes?
User avatar
SAPIEN Support Forums
Posts: 945
Joined: Wed Dec 03, 2014 2:26 pm

PrimalScript 2015 failed to show error line number with PV2

Postby SAPIEN Support Forums » Fri Oct 02, 2015 6:36 am

This is an automated post. A real person will respond soon.

Thank you for posting, clum09.

Did you remember to include the following?
    1. Product, version and build (e.g. Product: PrimalScript 2014, Version & Build: 7.0.46. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
    2. Specify if you are running a 32 or 64 bit version
    3. Specify your operating system and if it is 32 or 64 bit.
    4. Attach a screenshot if your issue can be seen on the screen
    5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.

If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***
User avatar
Alexander Riedel
Posts: 5865
Joined: Tue May 29, 2007 4:43 pm

Re: PrimalScript 2015 failed to show error line number with

Postby Alexander Riedel » Fri Oct 02, 2015 7:55 am

What you see is the output from the PowerShell engine, not something that PrimalScript generates.
Unfortunately we cannot change what any given PowerShell engine outputs as error. Only Microsoft can do that.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 114
Joined: Thu Apr 24, 2008 9:11 am

Re: PrimalScript 2015 failed to show error line number with

Postby clum09 » Fri Oct 02, 2015 9:16 am

When I ran this code in a console on a computer with PowerShell V2, I got the following error output:

Unexpected token '}' in expression or statement.
At C:\Scripts\Test.ps1:18 char:2
+ } <<<<
+ CategoryInfo : ParserError: (}:String) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken


As you can see, at least I can see what line generated the error.
User avatar
Alexander Riedel
Posts: 5865
Joined: Tue May 29, 2007 4:43 pm

Re: PrimalScript 2015 failed to show error line number with

Postby Alexander Riedel » Fri Oct 02, 2015 11:24 am

Notice the difference? You run this in V2 mode on a machine with PowerShell V4 and you get the original message.
You run it on a machine with a TRUE V2 installation you get a different message.

Microsoft never allows side-by-side installation of powershell versions.
So once you have V3,V4 or V5 installed, anything V2 is just a different mode of the same engine. It is not the same as using a real V2 engine.

Again, we do not generate, alter, modify, shorten or otherwise influence PowerShell error messages. What you see in the output window is what Powershell returns. We know it is inconsistent across versions and platforms. Please feel free to tell Microsoft about it.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 114
Joined: Thu Apr 24, 2008 9:11 am

Re: PrimalScript 2015 failed to show error line number with

Postby clum09 » Fri Oct 02, 2015 11:47 am

I did not run this script on a machine with multiple PowerShell versions installed.

I just copied this script to a computer that only had PowerShell version 2, and ran it in either the PowerShell console or within the PowerShell ISE.

The result is the same. The machine I ran this script has the following PowerShell version information as shown below.

PS C:\Users\TEST> $PSVersionTable

Name Value
---- -----
CLRVersion 2.0.50727.4963
BuildVersion 6.1.7600.16385
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1

The output from the ISE output windows or the PowerShell console is:

Unexpected token '}' in expression or statement.
At C:\Users\Testuser\Test.ps1:18 char:2
+ } <<<<
+ CategoryInfo : ParserError: (}:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken


compared to the output from PrimalScript 2015 in the PowerShell v2 mode, which is:

ERROR: <position> : Missing ] at end of type token.
ERROR: + CategoryInfo : ParserError: (Parameter(Mandatory=$true,:String) [], ParseException
ERROR: + FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfType
ERROR:

PrimalScript 2015 v2 mode just failed to capture the line number where the error occurred.
User avatar
Alexander Riedel
Posts: 5865
Joined: Tue May 29, 2007 4:43 pm

Re: PrimalScript 2015 failed to show error line number with

Postby Alexander Riedel » Fri Oct 02, 2015 12:06 pm

Again, PrimalScript does not fail to capture anything. You seem to imply that we intentionally withhold error information. We do not.
PrimalScript does not have some magical V2 mode that withholds errors. It just runs the installed Powershell engine in V2 mode. Same as if you start the console in V2 mode.

Run this on that machine where PrimalScript is installed in a V2 console.
If you compare the output from a V2 only machine to a V4 machine you will get different results, of course.

I am not sure how else to explain this.
Alexander Riedel
SAPIEN Technologies, Inc.

Return to “PrimalScript”

Who is online

Users browsing this forum: No registered users and 2 guests