Hi @João Ramos
It would've been helpful to the community to post the script you're using and the errors you're getting to best assist you. However, connecting to Microsoft Graph depends on which PowerShell your runbook using, i.e., 5.2 or 7 as there are different modules.
You can use the Connect-AzureAD
cmdlet to connect to Microsoft Graph in PowerShell 7, which is what I recommend. This cmdlet will use the context of automation account to connect Azure AD. However, if you wanted to use a different credential, you could use the following:
$credential = Get-AutomationPSCredential -Name 'GraphCredential'
Connect-AzureAD -Credential $credential
The Automation account should come preloaded with the Az modules but if you need to, you can use Import-Module Az
to add the modules. From there, you can you use Graph cmdlets you need.