Thanks for reaching out!! You can try to execute below Powershell commands to connect to Azure AD. Also please note that, make sure the service principle of RunAsConnection has necessary access to AD to invite the external uses.
# Login to Azure AD PowerShell With Admin Account
$connectionName="AzureRunAsConnection"
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
# Now you can login to Azure PowerShell with your Service Principal and Certificate
Connect-AzureAD -TenantId $servicePrincipalConnection.TenantId -ApplicationId $servicePrincipalConnection.ApplicationId -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
Here are some references that might help you.
1) Add guest user using PowerShell
2)
Bulk invite via Azure Portal
Hope this helps!!