Forum Discussion

Matt_P_Standing's avatar
Matt_P_Standing
Brass Contributor
Feb 13, 2024
Solved

Object reference not set when using New-MgInvitation with Runbook and Managed Identities

I am trying to send an AzureAD guest invitation using an Azure Runbook and GraphAPI. I have created a system managed identity for this (can successfully run Connect-MgGraph -identity in the runbook)....
  • Matt_P_Standing's avatar
    Feb 14, 2024

    I wasn't able to resolve this but found a workaround. Instead of using the dedicated PowerShell command I was able to use the REST API to generate the same request:

     

    $body = ConvertTo-Json -InputObject @{InvitedUserEmailAddress="email address removed for privacy reasons";InviteRedirectURL="https://myapps.microsoft.com";SendInvitationMessage= $true}
    
    $uri="https://graph.microsoft.com/v1.0/invitations"
    
    $response = Invoke-MgGraphRequest -method POST -Uri $URi -Body $Body

Resources