0 votes

I have a custom command that prompts for a "reporter" for our ticketing system for enabling VPN accounts. Sometimes a technician will enable an account on behalf of another user who is owner of the system affected. The parameter "Reporter" is an AD object picker. I then have an Action to create a Jira ticket using Powershell with that parameter as reporter. It also sends e-mail notification (additional action) to the vendor, the reporter, and the IT team. The To: box contains %mail% for the vendor (action is performed on an account),; %param-Reporter%; IT@domain.com. The %param-Reporter% thows an error because it's not an email address. How do I extract the email address of that object chosen as a parameter? Thank you.

by (70 points)

1 Answer

0 votes
by (288k points)

Hello,

This can only be done by sending the email notification using a PowerShell script. To send email notifications in PowerShell scripts, use the $Context.SendMail method. To get the email address of the user specified in the Custom Command parameter, use the below code, where param-MyParameter is the name of the parameter with the param- prefix:

$user = $Context.BindToObjectByDN("%param-MyParameter%")

try
{
    $userEmail = $user.Get("mail")    
}
catch
{
    $Context.LogMessage("The user specified in parameter 'MyParameter' has no email address. ", "Information")    
} 

Should you have issues writing the script, we will help you.

Related questions

0 votes
1 answer

I am working on a script that sends an email (using Send-MailMessage) to one or more recipients, selected through an AD Object Picker parameter within a custom command. I have ... picker before running the code so I am confused as to why this is not working.

asked Mar 4, 2022 by ryan741 (120 points)
0 votes
1 answer

Here is my issue, When I use this code: $DNs = %param-GroupsInRole% $Groups = $DNs -split "|" %Param-GroupsInRole% can have multiple groups. When setting up the parameter I am ... I just need to be able to do a foreach with the groups picked by the initiator.

asked Mar 23, 2023 by mightycabal (1.0k points)
0 votes
1 answer

Hi, I am Create a Custom Command. The Parameters UI Control is AD object picker. The Action is add the Parameters in Extension Attribute 1 But it will add the AD DN. If I want to add LogonName, what parameters should I enter?

asked Aug 2, 2021 by will.chc.join (90 points)
0 votes
1 answer

I have tried it using the Custom Commands Action "Add the user to a group", which only allows me to add the user to one group at a time, and can't use the multiple DNs that the ... I can't get it to work. Could you assist me in finding the best way to do this?

asked Jan 16 by dominik.stawny (280 points)
0 votes
1 answer

We have an AD Atturbute called HRManager which refferances AD accounts (like the manager attubute does) is there a way to get the email address of the referanced account in a script?

asked Jun 7, 2022 by hgletifer (1.3k points)
3,538 questions
3,229 answers
8,224 comments
547,747 users