Can't run an Azure PowerShell Script when Octopus installation path is contains spaces

I’m trying to run an Azure PowerShell script using Octopus Deploy, however I get an error:

Invoke-Expression : The term 'D:\Octopus' is not recognized as the name of a cmdlet, function, script file, or operable
 program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\Octopus Home Dir\Work\20161005094909-23\Octopus.AzureContext.ps1:86 char:2
+     Invoke-Expression ". $OctopusAzureTargetScript $OctopusAzureTargetScriptParamet ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\Octopus:String) [Invoke-Expression], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand
The step failed: The remote script failed with exit code 1

Octopus Deploy is installed in the following path: “D:\Octopus Home Dir”, so my guess is that this script doesn’t use quotes to safely allow spaces in paths. I first tried to debug the powershell script itself, but even when I comment away all the lines, I still get the error.

We’re working with version 3.3.19 of Octopus Deploy.

Hi David,

Thank you for getting in touch. I have reproduced this problem, raised an issue and fixed it in Calamari 3.2.28. I it should be included in the next release of Octopus (3.4.12), which I expect to be released today or tomorrow.

If you don’t want to wait, or don’t want to upgrade, you can download Calamari 3.2.28 and Calamari.Azure 3.2.28 (available in the next hour or so, once our integration tests pass) and follow these instructions to use it.

Hope that helps,

Robert W