Multiline Parameters failing for "Script File in Package" Powershell script

Hi Team,
I am using “Script” Step template to execute the powershell script from the Octo Package. However while passing PrivateSSHKey variable to the script it fails because it can not pass the multiline parameter to the script. If you can see highlighted parameter in the image below, thats the one that is failing.

I think I managed to get over this by surrounding the #{SFTPHostServer} in double quotes. and also put all script parameters in single line

However I am running into issues now that PrivateKey which is stored nicely as mutiline in Octopus but when passed to the script is converted into single line and causing invalid private key error.

Hey @harsh_tech,

Thanks for getting in touch! Great to hear you resolved your first question. I haven’t been able to reproduce your second issue, however. E.g. a multiline variable in Octopus passed in to the script remains multiline from my test locally.

My variable’s multiline value:

Task log:

Would you be willing to share a copy of your verbose task log where you’re hitting this issue? I’m hoping we can spot what might be happening within, along with giving us some more details like Octopus server version, etc. If you’re happy to share that, you can upload it here.

I look forward to hearing back and getting to the bottom of this one.

Best regards,

Kenny

Thanks @Kenneth_Bates would it be possible to test it with Sensitive? I have it as sensitive type.

Hi @harsh_tech,

Thanks for following up and my apologies for the delay in getting back to you on this one. I tested with changing the multiline variable to type sensitive and it looks like it’s still retaining the multiple lines, so no luck reproducing this behavior yet. Would you be willing to send through a copy of your verbose deployment log from an instance where you’re hitting this unexpected behavior? I’m hoping the details within will help us narrow down what might be going on.

Best regards,

Kenny

Thanks for trying it out. I uploaded the verbose logs now.

Hi @harsh_tech,

Thanks for following up and uploading the log. The following error seems to be indicating the SftpPrivateSSHKey value is remaining multiline:

13:36:39   Error    |       InvalidArgument: A positional parameter cannot be found that accepts argument '********
13:36:39   Error    |       ********\'.

Doing some reading it seems like there are a number of potential causes of this error.

It might be worth trying to rule out some of those possibilities, and I’d be happy to have a direct look if you’re willing to upload the exact script to the same upload link above?

Best regards,

Kenny

Thanks @Kenneth_Bates I uploaded the PowerShell. I think because private key is split across multiple lines, it got issue passing it to Process as argument.