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 (295k 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

We are using the below snippet to grab the email of a single custom attribute object. Can I get guidance on the best way to modify this to get all the emails of each ... "The user specified in parameter 'MyParameter' has no email address. ", "Information") }

asked Dec 23, 2024 by msheppard (660 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'm wondering if it's possible to export a list of all users in AD along with their email addresses to an Excel spreadsheet and then schedule that export to append ... address that wasn't previously used. Please let me know if this is possible. Thanks!

asked Apr 11, 2024 by sjjb2024 (60 points)
0 votes
1 answer

Hi Is it possible to get the Web Interface address via a script? Thanks Matt

asked Oct 13, 2023 by chappers77 (2.0k points)
3,605 questions
3,292 answers
8,342 comments
548,448 users