Issues of executing remote powershell script using cake-build

Question:

I am trying to execute following test.ps1 script

on remote server using following command

I was able to successfully invoke this command from command line and now I want the same using cake script.

I am using Cake.Powershell addin.

When I try to execute it with one curly brace {c:\\test.ps1 -name dato -password test} , I am getting error:

Error: Input string was not in a correct format.

When I try it with two curly brace

{{c:\\test.ps1 -name dato -password test}}

output is the following

Executing: Invoke-Command -ScriptBlock {{c:\test.ps1 -name dato -password test}}

but, when I check on remote server test.txt file is not created.

Do you have any ideas why this is happening?

Answer:

This is caused by the different handling of curly braces by the ProcessArgumentBuilder used internally by the Cake.Powershell addin, and the format parser used internally in Cake’s internal logger.

I submitted a PR to Cake.Powershell which has now been merged and a new release published, so upgrading to version 0.2.7 will resolve this issue for you.

You should then be able to use something like the following:

And while the log will include double braces, the actual command will only use single braces and should run correctly.

Source:

Issues of executing remote powershell script using cake-build by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply