0

Unable to append the notification email addresses on separate fields in Azure Service principal's SAML certificate notification email field.

I've tried the below; however, it adds to the existing notification email but not on separate notification email fields in Azure.

Notification email fields in Azure

$ServicePrincipalIDs = Get-Content C:\temp\spIds.txt Foreach($ServicePrincipalID in $ServicePrincipalIDs)

{

    $SP1 = Get-MgServicePrincipal -ServicePrincipalId "$ServicePrincipalID" 
    $SPDisplayName = $SP1.AppDisplayName
    
   
 
    $SP1NotificationDetails = $SP1.NotificationEmailAddresses += "hello@abc.com"


    Update-MgServicePrincipal -ServicePrincipalId "$ServicePrincipalID" -NotificationEmailAddresses "$SP1NotificationDetails"

}

Can you please let me know how do I append the email addresses instead of replacing the emails.

  • You need a semicolon between each email address. – jdweng Jun 14 '23 at 21:53
  • Thanks but is there a way to have it added to the existing notification email addresses. I am fetching the existing one and adding an additional email to them. But the whole list is appearing on one field. – Santhosh Durgam Jun 15 '23 at 01:03
  • Does this line really make any sense and where are you adding the semicolon? $SP1NotificationDetails = $SP1.NotificationEmailAddresses += "hello@abc.com" – jdweng Jun 15 '23 at 04:54
  • A small correction to that line. It is $SP1NotificationDetails += $SP1.NotificationEmailAddresses + "hello@abc.com". There is no "=" sign ( typo ). It basically picks the existing notification email addresses, appends "hello@abc.com" and stores these values in $SPNotificationDetails variable to be used in Update-MGServicePrincipal – Santhosh Durgam Jun 15 '23 at 05:54
  • You are still missing the semicolon – jdweng Jun 15 '23 at 08:58
  • The list is added on same field even if I add semicolon. $SP1NotificationDetails += $SP1.NotificationEmailAddresses + ";" +"hello@abc.com" Correct me if this is not the intended one. – Santhosh Durgam Jun 15 '23 at 09:14
  • Why would it be on a different field? – jdweng Jun 15 '23 at 12:26
  • hope you didn't get my question, I want the email addresses in Azure AD to be populated on separate fields as in the screenshot. – Santhosh Durgam Jun 15 '23 at 12:36

0 Answers0