Upgraded to 3.4.0, powershell step no longer works

I am not sure if Octopus Deploy is actually to blame here, but I want to record this for anybody else encountering this same issue
We have a powershell script template the contained the following line of code:

$applicationVersion = $( $OctopusParameters[‘Octopus.Release.Number’] -Replace “(.)-(.)”, "$1" -Replace ‘.’, ‘_’ )

Prior to 3.4.0, it worked fine in one of our older deployment servers (Windows 2008 R2, PowerShell v2), no problems. After upgrading to 3.4.0 where nothing else had changed in the environment or deployment scripts, the following error started occurring:

Unexpected token ‘` -Replace’ in expression or statement.
August 25th 2016 12:27:45Error
At C:\Deployments\Octopus\Work\20160825002742-73\Script.ps1:2 char:109
August 25th 2016 12:27:45Error

  • $applicationVersion = $( $OctopusParameters[‘Octopus.Release.Number’] -Replac
    August 25th 2016 12:27:45Error
    e “(.)-(.)”, "$1" -Replace <<<< ‘.’, ‘_’ )
    August 25th 2016 12:27:45Error
    • CategoryInfo : ParserError: (` -Replace:String) [], ParentConta
      August 25th 2016 12:27:45Error
      insErrorRecordException
      August 25th 2016 12:27:45Error
    • FullyQualifiedErrorId : UnexpectedToken

We found that upgrading from Powershell v2 to Powershell v3 solved the issue.
We are not sure if Octopus has any impact on the powershell scripts, but it seems suspious that the only change to the server was a tentacle upgrade to 3.4.0 and then the script started failing.

Is it possible that 3.4.0 is dependent on Powershell v3 or higher, where v3.4.0-beta002 was not?
Was Octopus always dependent on Powershell v3, but for some reason we’ve managed to get away with it up until this release?

If anybody encounters their powershell scripts suddenly failing after upgrading to v3.4.0, upgrading to Powershell v3.0 solved the issue for me.

Hi Rhys,

Thanks for getting in touch!

I’m not sure why upgrading to 3.4.0 would’ve broken that script for you, I’ve run it on a 3.2.3 instance running on Windows Server 2008R2 with PowerShell 2.0 and I get that same error. I also ran it on a server with PS5.0 and it also gives me the same error.

I’m glad to hear that you managed to get it fixed though!

Thank you and best regards,
Henrik

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.