Are we forced to use Write-Output?

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
Jehoschua
Posts: 64
Last visit: Fri Mar 01, 2024 3:24 am

Are we forced to use Write-Output?

Post by Jehoschua »

Good evening

It's sad that we can not search for "Output" or "Write-Output" just in the Sapien Forum subjects - I'm pretty sure we are not the 1st Powershell Studio users with this problem...

If we *debug* a simple Powershell script in Powershell Studio:
"Hello Line 1"
"Hello Line 2"
Then we expect to get the Text "Hello Line 1" and "Hello Line 2" in the Output console.
But the Powershell Studio debugger changes the default Powershell handling of strings and they are not printed to the Output console.
We have to write this:
Write-Output "Hello Line 1"
Write-Output "Hello Line 2"
This is annyoing, because debugging should never change how a subject under test is handled.
Is there a way to get the default Powershell handling for strings in the Powershell Studio debugger?

Thanks a lot in advance,
kind regards,
Thomas
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Are we forced to use Write-Output?

Post by DevinL »

So far, I've been unable to reproduce the results you're describing. This could be because I'm not understanding correctly so let me outline what I've tested to see where our paths differ:

I created a script with only 3 lines:
  1. "Test line 1"
  2. "Test line 2"
  3. "Test line 3"
I place a breakpoint on line 3 and begin debugging (F5), here are the results in the Output Panel:
Debugging_Strings.png
Debugging_Strings.png (130.67 KiB) Viewed 2580 times
What am I doing differently from you? As soon as I have some more information I'll gladly look into this for you.
DevinL
SAPIEN Technologies, Inc.
User avatar
Jehoschua
Posts: 64
Last visit: Fri Mar 01, 2024 3:24 am

Re: Are we forced to use Write-Output?

Post by Jehoschua »

Good morning DevinL

Thank you very much for your fast and detailed answer!!,
Today, the problem disappeared and therefore I've spend some time to investigate it because I had the same behavior some weeks ago.

Using the following small change, I can reproduce the problem:
Strange Debug Session: Output "Hello 1" is missing
Strange Debug Session: Output "Hello 1" is missing
Debugsession1.png (51.08 KiB) Viewed 2553 times
This example leads to a delayed output: if you continue debugging, the missing output will appear.

I would have bet that I've got the situation where the output were completely missing, but today, I am not able to reproduce it.

Kind regards,
Thomas
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Are we forced to use Write-Output?

Post by DevinL »

I would like to verify real quick that the issue is your output isn't appearing in the Output panel when you hit the breakpoint in your screenshot, am I correct? I ask because your screenshot shows the Variables and Debug panel, and I wasn't sure if they were somehow related to this issue.

That aside, if the issue does crop up again please let us know and we'll look into further. It's usually when we want to reproduce a bug that we're unable to :lol:
DevinL
SAPIEN Technologies, Inc.
User avatar
Jehoschua
Posts: 64
Last visit: Fri Mar 01, 2024 3:24 am

Re: Are we forced to use Write-Output?

Post by Jehoschua »

Good evening DevinL

Thank you very much for your feedback!,
yes, you're right, in my debug-session the Debug panel was active
and all strings were printed perfectly on the Output panel.

I will keep trying to reproduce my problem...

I'm very sorry for the troubles.

Kind regards,
Thomas
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Are we forced to use Write-Output?

Post by DevinL »

No problem at all! Best of luck :)
DevinL
SAPIEN Technologies, Inc.
This topic is 7 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.