Forum Discussion
Matt_P_Standing
Feb 13, 2024Brass Contributor
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)....
- 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
Matt_P_Standing
Feb 14, 2024Brass Contributor
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