Determine Previous Installed Project Version in Powershell


I’m trying to write a powershell script to run certain files based on the current deployment version Octopus.Release.Number . My best solution would be to run updates based on what was previously installed. So for example -
Project Website A had released version installed in Environment Test. the latest release being installed to Test is Knowing what the previous installed release is, I can execute the right update files that are stored based on the 3rd octet of the version.

In short, is there an easy way to know what release was last published to the environment that an active deployment is running on. With this I can run custom powershell for completely automated upgrade.



Hi Luis,

Currently the best solution available for this is to use a PowerShell script during deployment to write the “current” release to a file on the target machine. Then during the next deployment, this can be read back in before overwriting it with the newer value.

We’re actively investigating ways to make Octopus work better for this scenario, but there are a few “gotchas” we need to sort out before we can offer it.

Hope this helps,

Is there a way to retrieve it via api?

I haven’t looked much into the api so I’m not sure.

Hi Luis - there’s information about the current release deployed to an environment via the API’s /api/dashboard resource, and via the /api/deployments resource, depending on whether you need all deployments or just successful ones.

This is error-prone for what you want to do though, because it doesn’t give per-machine information, and doesn’t account for environmental changes (new machine added, VHD snapshot reverted, etc.)


I’ll close this as I’ll look into using the two options.

Having the previously installed version in variable would also be of great benefit to automate rollbacks should something fail in current release.

Thanks for your help. I’m nothing but happy to have purchased this product for my work.