Recently, I have been getting the above error during a deployment at the very end of the PostDeploy.ps1 script.
So I looked around and saw that we can run the calamari run-script command (https://octopus.com/docs/deploying-applications/custom-scripts) manually to see if I get the same result.
As you can tell, the error is not happening at all when running it manually.
I am running 2018.5.1. This first started happening, IIRC, with build 2018.4.12.
Everything runs fine on the product that is being installed, it is just not encouraging to see the RED status when it is executed through the UI, but manually it is fine.
Thanks in advance.