Error of "Cannot find the specified file" when running a script on Octopus 3.1.1

I am running Octopus 3.1.1 and target machine is a CentOS 6.6 VM.

When I run a PowerShell which tries to create a directory under home directory, I got the following error. I checked the home directory and I found the directory of “20151005175931-123” does not exist under “.octopus/OctopusServer/Work”.

===================================================
Error is as the follows

The step failed: One or more child activities failed.

System.Exception: Error when attempting to execute PowerShell.exe: ApplicationName=‘PowerShell.exe’, CommandLine=’-NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command “. {. ‘/home/hadoopdev/.octopus/OctopusServer/Work/20151005175931-123/Bootstrap.script.ps1’ -key ‘2ZfT5/4f6OMUqFkosnTHtQ==’; if ((test-path variable:global:lastexitcode)) { exit $LastExitCode }}”’, CurrentDirectory=’/home/hadoopdev/.octopus/OctopusServer/Work/20151005175931-123’, Native error= Cannot find the specified file —> System.ComponentModel.Win32Exception: ApplicationName=‘PowerShell.exe’, CommandLine=’-NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command “. {. ‘/home/hadoopdev/.octopus/OctopusServer/Work/20151005175931-123/Bootstrap.script.ps1’ -key ‘2ZfT5/4f6OMUqFkosnTHtQ==’; if ((test-path variable:global:lastexitcode)) { exit $LastExitCode }}”’, CurrentDirectory=’/home/hadoopdev/.octopus/OctopusServer/Work/20151005175931-123’, Native error= Cannot find the specified file
10:59:38Error
at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in :0
10:59:38Error
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in :0
10:59:38Error
at System.Diagnostics.Process.Start () [0x00000] in :0
10:59:38Error
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
10:59:38Error
at Calamari.Integration.Processes.SilentProcessRunner.ExecuteCommand (System.String executable, System.String arguments, System.String workingDirectory, System.Action1 output, System.Action1 error) [0x00000] in :0
10:59:38Error
— End of inner exception stack trace —
10:59:38Error
at Calamari.Integration.Processes.SilentProcessRunner.ExecuteCommand (System.String executable, System.String arguments, System.String workingDirectory, System.Action1 output, System.Action1 error) [0x00000] in :0
10:59:38Error
at Calamari.Integration.Processes.CommandLineRunner.Execute (Calamari.Integration.Processes.CommandLineInvocation invocation) [0x00000] in :0
10:59:38Error
The command that caused the exception was: “PowerShell.exe” -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command ". {. ‘/home/hadoopdev/.octopus/OctopusServer/Work/20151005175931-123/Bootstrap.script.ps1’ -key ‘2ZfT5/4f6OMUqFkosnTHtQ==’; if ((test-path variable:global:lastexitcode)) { exit $LastExitCode }}"
10:59:39Error
The remote script failed with exit code 255

Hi Edward,
Since PowerShell is a windows command line shell I wouldnt expect it to work in anything *Nix based. That’s why the error is actually saying unable to find\execute PowerShell.exe as it wont exist. That being said we should probably give a cleaner and more obvious exception if a user attempts to run PowerShell on a *Nix machine. I have created GH Issue #2048 to better handle this error.
If you instead write your script in either Bash or C# then it should execute fine on your machine.
Give this a try and let me know how it goes.
Thanks,
Rob