0

I'm writing a runbook/workflow like below according to this blog:

workflow Do-RemoteInlineScript
{
    $uri = ...
    $credential = ...

    $result = InlineScript
    {
        <commands>   
    } -PSConnectionUri $uri -PSCredential $credential
}

When I run it, I will get the exception Cannot bind parameter 'ScriptBlock'.

Where do I err?

Note: My problem seems to be related to this msdn-post.

1 Answer 1

1

Azure Automation currently has a bug where InlineScript cannot target a remote system, as you are trying to do above. The workaround is to put an Invoke-Command in the InlineScript and have this cmdlet target the remote system:

$PSCommandResult = InlineScript {         
    Invoke-Command -ConnectionUri $Using:Uri -Credential $Using:Credential -ScriptBlock { 
        <commands>
    }
}

See the Invoke-Command sample-runbook for more details.

Sign up to request clarification or add additional context in comments.

2 Comments

I am aware of this workaround. Do you have a reference for the bug?
Just the link you already mentioned: social.msdn.microsoft.com/Forums/sqlserver/en-US/…. I am a member of the Azure Automation team though, so I can tell you it is a bug, and not intended behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.