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
11:49:23Error
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
11:49:23Error
At D:\Octopus Home Dir\Work\20161005094909-23\Octopus.AzureContext.ps1:86 char:2
11:49:23Error
+ Invoke-Expression ". $OctopusAzureTargetScript $OctopusAzureTargetScriptParamet ...
11:49:23Error
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11:49:23Error
+ CategoryInfo : ObjectNotFound: (D:\Octopus:String) [Invoke-Expression], CommandNotFoundException
11:49:23Error
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand
11:49:23Error
11:49:23Fatal
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.