Welcome to Microsoft Q&A! I regret the delayed response.
Can you please test if this script works on a machine outside of Azure Automation runbook? This would help isolate the issue to permission/scripting issue from Azure Automation.
Also, the error being received is generic TaskCanceledException
. I would suggest using try{}
catch{}
in the runbook to be able to gather more details on the error as below:
try {
#Code that is/can throwing exception.
}
catch {
Write-Output $_.Exception.ToString() #Gets full details of the exception with stack
Write-Output $_.Exception.InnerException.ToString() #to get associated InnerException if any. This is usefull when the cought exception is different from the one that caused it.
}
You may also refer to this link for some common errors with runbook execution.
Please let me know if have any questions.
---
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.