Here-String not working PowerShell Studio 2019

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 5 years and 3 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
theotherkidd
Posts: 21
Last visit: Wed May 05, 2021 2:24 pm

Here-String not working PowerShell Studio 2019

Post by theotherkidd »

Product, version and build: PowerShell Studio 2019 5.6.156.0
32 or 64 bit version of product: 64 bit
Operating system: Windows 10
32 or 64 bit OS: 64 bit

I have a GUI app that uses a here-string to format output to a text file. After installing PowerShell Studio 2019, this is no longer working. The text file outputs the data without the format I've set with the here-string. It seems to be ignoring line feeds. However, it works fine if I run it from the PowerShell Studio IDE. Problem only occurs when I convert to an EXE or I install via a MSI.

The formating still works fine in the PowerShell Studio 2018 version of the app.

Please advise. Thanks.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Here-String not working PowerShell Studio 2019

Post by davidc »

In order to investigate, please zip the psf or project and upload it here:

https://www.sapien.com/support/upload

Be sure to include the psbuild file so we know what settings you are using.
Also, please include the text files for before and after the update (if possible).
David
SAPIEN Technologies, Inc.
User avatar
theotherkidd
Posts: 21
Last visit: Wed May 05, 2021 2:24 pm

Re: Here-String not working PowerShell Studio 2019

Post by theotherkidd »

Hey David,
I was able to work around the issue. I changed the code to open the output file in notepad++ instead of notepad and the formatting is correct. Not sure why the formatting is off in notepad now since I upgraded. On an interesting note, if I cut and paste the incorrectly formatted text from notepad to notepad++ or even to a UNIX file, the data is pasted in with the right format. I'm fine with using notepad++.

Correct format:
1,SERVER01
2,SERVER01
3,1.1.1.1
1,SERVER02
2,SERVER02
3,1.1.1.2
1,SERVER03
2,SERVER03
3,1.1.1.3

Incorrect format:
1,SERVER01,2,SERVER01,3,1.1.1.1
1,SERVER02,2,SERVER02,3,1.1.1.2
1,SERVER03,2,SERVER03,3,1.1.1.3

Thanks for your response
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Here-String not working PowerShell Studio 2019

Post by davidc »

This sounds like a line ending issue. Usually Notepad expects CRLF (`r`n) line endings and if it is just LF (`n) it will show the text all on the same line.
David
SAPIEN Technologies, Inc.
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Here-String not working PowerShell Studio 2019

Post by mxtrinidad »

In your example, you are missing how are you storing the values in the here-string.
Are you using single or double quotes? How are you displaying the values?

It's important to provide some kind of sample code to reproduce the issue you're experiencing.
This will help greatly.
User avatar
theotherkidd
Posts: 21
Last visit: Wed May 05, 2021 2:24 pm

Re: Here-String not working PowerShell Studio 2019

Post by theotherkidd »

Here's gnerally what I have:
  1. @"
  2. 1,$Server
  3. 2,$ServerLoc
  4. 3,$IPAddress
  5. "@ | Out-File $outputFile -Encoding ASCII -Append
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Here-String not working PowerShell Studio 2019

Post by mxtrinidad »

This is Great!

Thanks for providing the sample code. We'll be doing some test and get back to you soon.
This topic is 5 years and 3 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.