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

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

Viewing 5 reply threads
  • Author
    Posts
    • #178947
      Participant
      Topics: 6
      Replies: 11
      Points: 100
      Rank: Participant

      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: 1152
      Points: 4,000
      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: 100
      Rank: Participant

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

    • #178974
      Participant
      Topics: 0
      Replies: 28
      Points: 142
      Helping Hand
      Rank: Participant

      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: 105
      Points: 249
      Helping Hand
      Rank: Participant

      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: 100
      Rank: Participant

      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

Viewing 5 reply threads
  • The topic ‘Get AD members (including contacts) name & E-mails’ is closed to new replies.