Get AD members (including contacts) name & E-mails

Welcome Forums General PowerShell Q&A Get AD members (including contacts) name & E-mails

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
3 weeks, 5 days ago.

  • Author
    Posts
  • #178947

    Participant
    Topics: 6
    Replies: 11
    Points: 97
    Rank: Member

    Hello,

     

    I have a short line for the above mentioned:

    Get-ADGroup "group" -Properties member | Select-Object -ExpandProperty member | Get-ADObject | select name | sort name

    which provides the names of the group members.
    i want the email addresses of the users and contacts.
    I've tried: select name,e-mail / name,emailaddress / name,mail – nothing worked for me, all returned empty <>

    Please Help, thanks.

  • #178950

    Senior Moderator
    Topics: 8
    Replies: 1085
    Points: 3,651
    Helping Hand
    Rank: Community Hero

    You could use Get-ADGroupMemeber and Get-ADUser together to achieve this

    Get-ADGroupMember "group" | Get-ADUser -Properties mail | Select-Object -Property Mail
    
  • #178953

    Participant
    Topics: 6
    Replies: 11
    Points: 97
    Rank: Member

    thanks but it's return only the emails and only of the users, without contacts

  • #178974

    Participant
    Topics: 0
    Replies: 18
    Points: 77
    Helping Hand
    Rank: Member

    Read the below thread which will give you some idea

    https://powershell.org/forums/topic/get-active-directory-contact-information/

  • #178980

    Participant
    Topics: 4
    Replies: 76
    Points: 91
    Helping Hand
    Rank: Member

    Hi,

    Get-adgroupmember does not include contacts.

    https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-adgroupmember?view=win10-ps
    The Get-ADGroupMember cmdlet gets the members of an Active Directory group. Members can be users, groups, and computers.

    You need to do it the other way by finding adobjects who are member of the desired group.

    
    $group = get-adgroup 'group' | select -ExpandProperty distinguishedname
    Get-ADObject -filter * -Properties memberof,mail | where {$group -contains $_.memberof} | select mail
    
    
  • #179235

    Participant
    Topics: 6
    Replies: 11
    Points: 97
    Rank: Member

    Hi,

    Get-adgroupmember does not include contacts.

    https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-adgroupmember?view=win10-ps

    The Get-ADGroupMember cmdlet gets the members of an Active Directory group. Members can be users, groups, and computers.

    You need to do it the other way by finding adobjects who are member of the desired group.

    PowerShell
    5 lines

    1
    2
    3
    4
    5
    $group = get-adgroup 'group' | select ExpandProperty distinguishedname
    Get-ADObject -filter * Properties memberof,mail | where {$group -contains $_.memberof} | select mail
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thanks, that worked for me

You must be logged in to reply to this topic.