Note: if i run the above script on the server directly it works fine but with octopus it gave an error, but if i remove credential arguments from script then it works fine in octopus also but i want to use different credential for this specific script.
Could you please try to recreate and let me know how can i resolve it.
Thanks for reaching out! It looks like you’re running into this error because the domain\Octopus1 account isn’t able to run the script for some reason.
If you haven’t read it already, we have some documentation on Running Tentacles under a specific account. Could you try running the tentacle as a local administrator to see if it works that way, please?
It is perfectly able to run scripts but it’s not able to run those scripts which uses invoke-command,start-process and start-job with different credentials.
For example if I run below script it will run successful.
Script:
Start-Job -ScriptBlock{Get-Service}