@raorla , thank you for posting this question.
I see that you are using
connect-MSGraph which requires interactive authentication. Interactive authentication is not supported in Azure Automation. For more details of how the execution and authentication works in Azure Automation, please see Runbook execution environment
connect-MSGraph in Runbooks, you would have to use one of the non-interactive methods for authentication as mentioned here - App-only access via client credential with a certificate. Use the third method (using certificate in this doc).
Hope this helps.
If the answer did not help, please add more context/follow-up question for it, and we will help you out. Else, if the answer helped, please click Accept answer so that it can help others in the community looking for help on similar topics.