Page 1 of 1

Here-String not working PowerShell Studio 2019

Posted: Tue Dec 11, 2018 5:17 pm
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.

Re: Here-String not working PowerShell Studio 2019

Posted: Wed Dec 12, 2018 9:18 am
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).

Re: Here-String not working PowerShell Studio 2019

Posted: Wed Dec 12, 2018 2:53 pm
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

Re: Here-String not working PowerShell Studio 2019

Posted: Wed Dec 12, 2018 3:49 pm
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.

Re: Here-String not working PowerShell Studio 2019

Posted: Thu Dec 13, 2018 6:48 am
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.

Re: Here-String not working PowerShell Studio 2019

Posted: Thu Dec 13, 2018 7:17 am
by theotherkidd
Here's gnerally what I have:

Code: Select all

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

Re: Here-String not working PowerShell Studio 2019

Posted: Thu Dec 13, 2018 7:26 am
by mxtrinidad
This is Great!

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