locked
Connect-AzureAD in Azure Automation Runbook RRS feed

  • Question

  • I'm trying to run New-AzureADMSInvitation using the Azure runbook but am prompted with an error to first use Connect-AzureAD before I can use it.

    I've tried signing in many times but I must be doing something wrong, getting all sorts of different errors from the different methods I found online to sign in.



    What is the proper syntax or what is the correct way of going about using Connect-AzureAD to authorize in an Azure runbook?



    Any help is appreciated 




    Wednesday, May 13, 2020 6:14 PM

All replies

  • 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!!

    Wednesday, May 27, 2020 4:53 AM