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 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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
theotherkidd
Posts: 16
Joined: Tue Mar 09, 2010 4:44 am

Here-String not working PowerShell Studio 2019

Post by theotherkidd » Tue Dec 11, 2018 5:17 pm

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
Joined: Thu Aug 18, 2011 4:56 am

Re: Here-String not working PowerShell Studio 2019

Post by davidc » Wed Dec 12, 2018 9:18 am

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: 16
Joined: Tue Mar 09, 2010 4:44 am

Re: Here-String not working PowerShell Studio 2019

Post by theotherkidd » Wed Dec 12, 2018 2:53 pm

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
Joined: Thu Aug 18, 2011 4:56 am

Re: Here-String not working PowerShell Studio 2019

Post by davidc » Wed Dec 12, 2018 3:49 pm

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
Site Admin
Posts: 352
Joined: Sun Mar 03, 2013 12:42 pm

Re: Here-String not working PowerShell Studio 2019

Post by mxtrinidad » Thu Dec 13, 2018 6:48 am

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: 16
Joined: Tue Mar 09, 2010 4:44 am

Re: Here-String not working PowerShell Studio 2019

Post by theotherkidd » Thu Dec 13, 2018 7:17 am

Here's gnerally what I have:

Code: Select all

@"
1,$Server
2,$ServerLoc
3,$IPAddress
"@ | Out-File $outputFile -Encoding ASCII -Append

User avatar
mxtrinidad
Site Admin
Posts: 352
Joined: Sun Mar 03, 2013 12:42 pm

Re: Here-String not working PowerShell Studio 2019

Post by mxtrinidad » Thu Dec 13, 2018 7:26 am

This is Great!

Thanks for providing the sample code. We'll be doing some test and get back to you soon.