Process is not running with different credential in octopus

Team,

We have a requirement where I am running a script on a particular server via octopus.

Octopus Tentacle service account is domain service account (domain\Octopus1) where interactive logon is disable.

the script which I am running is below and this is just a sample script to explain the scenario better.

Script:
$Pass = ConvertTo-SecureString “Password@123” -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential (“domain\User1”, $Pass)
$j = Start-Job -ScriptBlock{Get-Service} -Credential $ServiceAccountCred
Receive-Job $j -Wait

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.

Hi @mohitmishra.mishra1989

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?

Regards,

Hi @stuart.mcilveen ,

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}

But if I run below one then it will give error.

$Pass = ConvertTo-SecureString “Password@123” -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential (“domain\User1”, $Pass)
$j = Start-Job -ScriptBlock{Get-Service} -Credential $ServiceAccountCred

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.