0 votes

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?

by (1.3k points)

1 Answer

0 votes
by (257k points)
selected by
Best answer

Hello,

Yes, it is possible using the below script for a DN syntax property like the Manager one. In the script, the $propertyName variable specifies the LDAP name of the property.

$propertyName = "manager" #TODO: modify me

# Get the object DN
try
{
    $dn = $Context.TargetObject.Get($propertyName)
}
catch
{
    $Context.LogMessage("Property $propertyName is empty.", "Information")
    return
}

# Get object email
try
{
    $object = $Context.BindToObjectByDN($dn)
    $objectEmail = $object.Get("mail")
}
catch
{
    $Context.LogMessage("Object with DN $dn does not exist or has no email specified.", "Information")
    return
}

Related questions

0 votes
1 answer

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 ... do I extract the email address of that object chosen as a parameter? Thank you.

asked Dec 10, 2019 by bjzielinski (70 points)
0 votes
1 answer

Hello, I don't find an attribute for the netbios name of managed Domains like adm-DomainDN? How can I add the NetBios name to a report like "All users"? regards Helmut

asked Mar 5, 2021 by a423385 (510 points)
0 votes
1 answer

Hello, i have a custom command which sets the oof-message for the selected user. in this custom command i have a parameter "param-vertretung" (ad-object picker). Now i want to ... and email of the stand-in in the oof-message. Can you help me with that? Thanks

asked Nov 13, 2020 by lohnag (140 points)
0 votes
1 answer

My security team is looking to do a security review and would like the vendor to fill out a questionnaire.

asked Aug 25 by LarrySargent (20 points)
0 votes
1 answer

Hi We've had a request to forward to a mailbox any user who has had their username and email address changed, the email is to show old user name, new user name, old ... and email address, would it need to be a Powershell script for this? Thanks in advance.

asked Jan 23, 2015 by CBurn (700 points)
3,167 questions
2,870 answers
7,362 comments
506,059 users