msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

New-MgInvitation cc email not sending

Open stottler opened this issue 2 years ago • 4 comments

Describe the bug I am unable to send a CC email for a new invited user in EntraID.

To Reproduce Steps to reproduce the behavior:

$params = @{
	invitedUserEmailAddress = $Intern_Microsoft_Account_Email
    invitedUserDisplayName = $Intern_fullname
    invitedUserType = "Guest"
    sendInvitationMessage = $true
	inviteRedirectUrl = "https://myapplications.microsoft.com"
    invitedUserMessageInfo = {
        CustomizedMessageBody = $email_text
        ccRecipients = {
               emailAddress = {
                   address = "email here"
                   name = "name here"
                }
            }
       
    }
}

New-MgInvitation -BodyParameter $params 

Expected behavior I'm expecting to see an invite drop into my cc'd inbox but it's not. Debug isn't showing one either.

Debug Output

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://graph.microsoft.com/v1.0/invitations

Headers:
FeatureFlag                   : 00000043
Cache-Control                 : no-store, no-cache
User-Agent                    : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22621; en-US),PowerShell/2024.0.0
Accept-Encoding               : gzip
SdkVersion                    : graph-powershell/2.12.0
client-request-id             : 52895ab1-36a1-4005-aeae-df2eb758af54

Body:
{
  "invitedUserDisplayName": "redacted",
  "invitedUserEmailAddress": "redacted",
  "invitedUserType": "Guest",
  "inviteRedirectUrl": "https://myapplications.microsoft.com",
  "sendInvitationMessage": true
}


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
Created

Headers:
Cache-Control                 : no-store, must-revalidate, no-cache
Location                      : https://graph.microsoft.com/
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : 12372270-4caf-4095-9333-695bc60a8d31
client-request-id             : 52895ab1-36a1-4005-aeae-df2eb758af54
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"Canada East","Slice":"E","Ring":"2","ScaleUnit":"001","RoleInstance":"QB1PEPF00004D4D"}}
odata-version                 : 4.0
Date                          : Thu, 01 Feb 2024 18:41:42 GMT

Body:
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#invitations/$entity",
  "id": "9e60643b-4c95-4c1f-8c57-8b831ea75484",
  "inviteRedeemUrl": "https://login.microsoftonline.com/redeem?rd=https%3a%2f%2finvitations.microsoft.com%2fredeem%2f%3ftenant%3da46a263e-a319-4a4e-956b-e0603b9294b6%26user%3d9e60643b-4c95-4c1f-8c57-8b831ea75484%26ticket%3dVlU8vjmMLsU9Jw9eCBNt%25252fBZywJaB24Anb2m%25252bWZZhiOA%25253d%26ver%3d2.0",
  "invitedUserDisplayName": "redacted",
  "invitedUserType": "Guest",
  "invitedUserEmailAddress": "redacted",
  "sendInvitationMessage": true,
  "resetRedemption": false,
  "inviteRedirectUrl": "https://myapplications.microsoft.com/",
  "status": "PendingAcceptance",
  "invitedUserMessageInfo": {
    "messageLanguage": null,
    "customizedMessageBody": null,
    "ccRecipients": [
      {
        "emailAddress": {
          "name": null,
          "address": null
        }
      }
    ]
  },
  "invitedUser": {
    "id": "redacted"
  }
}



DEBUG: [CmdletEndProcessing]: - New-MgInvitation end processing.

Module Version

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.12.0                Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-M… 
Script     2.12.0                Microsoft.Graph.Groups              {Add-MgGroupDriveListContentTypeCopy, Add-MgGroupDriveListCont… 
Script     2.12.0                Microsoft.Graph.Identity.SignIns    {Confirm-MgRiskyServicePrincipalCompromised, Confirm-MgRiskyUs… 
Script     2.12.0                Microsoft.Graph.Users               {Get-MgUser, Get-MgUserCount, Get-MgUserCreatedObject, Get-MgU… 

Environment Data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context I'm trying to automate created external users in our EntraID. I have a json file as the input (this part has been figured out).

stottler avatar Feb 01 '24 18:02 stottler

still no luck with CC'ing

stottler avatar Feb 08 '24 16:02 stottler

I've had the same issue and raised the issue elsewhere, but finally cracked it. Your hash table is not quite correct for invitedUserMessageInfo. I also had to use the beta module New-MgBetaInvitation, but below should help you.

$InvitedUserMessageInfo = @{
	CustomizedMessageBody = "Welcome!"
	ccRecipients = @(
		@{
			emailAddress = @{
				address = "[email protected]"
			}
		}
	)
}

New-MgInvitation -InvitedUserDisplayName "User" -InvitedUserEmailAddress "[email protected]" -InviteRedirectUrl "https://myapplications.microsoft.com" -InvitedUserMessageInfo $InvitedUserMessageInfo -SendInvitationMessage -Debug

s-fordham avatar Mar 27 '24 11:03 s-fordham

@sebastienlevert examples need to be enriched i.e. Fusing imported examples from the API reference docswith hand-written examples. cc: @SteveMutungi254

timayabi2020 avatar Apr 03 '24 10:04 timayabi2020

Having the docs be updated would be great, thanks.

stottler avatar Apr 03 '24 12:04 stottler