Page 1 of 1

Saving and sign script removes last charactor in script

Posted: Tue Mar 19, 2019 12:20 am
by jessondergaard
To help you better we need some information from you.

Product, version and build: SAPIEN PowerShell Studio 2019, Version 5.6.160
32 or 64 bit version of product: 64 bit
Operating system: Windows 10 Enterprise 1709 OS Build 16299.1029
32 or 64 bit OS: 64 Bit

*** Please add details and screenshots as needed below. ***
When ever I save my script on PowerShell Studio it removes at last charactor in the script.
It seems to be related to the automatic signing of the script.
However it does not happen when I just select "Sign Script".
If I remove the setting to automatically sign the script on save, the error is gone.

Re: Saving and sign script removes last charactor in script

Posted: Tue Mar 19, 2019 7:21 am
by davidc
Is the file using Unix line ends?

Re: Saving and sign script removes last charactor in script

Posted: Tue Mar 19, 2019 7:45 am
by davidc
If you are using Unix line endings, the signing process unfortunately chops the last line because it expects and uses Windows line ends.
I will ask the Dev team to look into it, but since the signing process is external, I'm not sure there much we can do.

Re: Saving and sign script removes last charactor in script

Posted: Tue Mar 19, 2019 8:59 am
by davidc
I confirmed this also occurs if you use the Set-AuthenticodeSignature cmdlet.

Re: Saving and sign script removes last charactor in script

Posted: Tue Mar 19, 2019 9:03 am
by Alexander Riedel
It's a bug in the WIndows API basically, it assumes that ALL files are CR/LF and acts accordingly. We will see what we can do as a workaround.

Re: Saving and sign script removes last charactor in script

Posted: Tue Mar 19, 2019 10:37 pm
by jessondergaard
I have now changed the file to use Windows CRLF line ends and then the problem is gone.
I was not aware of this, an actually not sure why the files was in Unix format. So this workaround is good enough for me.

Thank you for your quick help on this.

Re: Saving and sign script removes last charactor in script

Posted: Wed Mar 20, 2019 7:38 am
by davidc
We made some changes to hopefully work around the issue in case someone else uses Unix line endings.

Re: Saving and sign script removes last charactor in script

Posted: Tue Apr 09, 2019 10:44 am
by davidc
We released the v5.6.161 service build that includes the work around.