When running below workflow in ISE on my Azure Automation Hybrid Runbook Worker it works just fine. When executing the same workflow through Azure Automation I get:
Connecting to remote server servername failed with the following error message : Access is denied.
I also tried to execute the Runbook using runas with the same account I used logging into the Hybrid Runbook Worker to run the workflow in ISE. The target server and the Hybrid Runbook Worker are both domain joined, although in different domains.
Could it be that executing the workflow through Azure Automation introduces another hop and I run into a multi-hop issue?
workflow Temp
{
$User = 'domain\username'
$Password = ConvertTo-SecureString 'password' -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ($User, $Password)
hostname
[Environment]::UserName
InlineScript
{
hostname
[Environment]::UserName
} -PSCredential $Credentials -PSComputerName servername
}