Users' desciption is not showing any info on PowerShell

IT 140 Reputation points
2023-11-09T10:50:29.4833333+00:00

Please guide me on how to add the descrption to the result of the PowerShell command

Get-DistributionGroupMember -Identity studentsblockexternal@alkauthar.academy | ft displayname, primarySMTPaddress, description

Get-DistributionGroupMember -Identity <DLIdentity> | ft displayname, primarySMTPaddress

Also I want to know the total of members for this group if possible.User's image

User's image

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Luis Arias 8,621 Reputation points Volunteer Moderator
    2023-11-09T12:36:20.52+00:00

    Hi IT,

    I recommend you use AD cmdlets after you get user membership of the group:

    $groupName = "YourDistributionGroupName"
    
    Get-DistributionGroupMember -Identity $groupName | ForEach-Object {
        $user = Get-ADUser -Identity $_.SamAccountName -Properties DisplayName, EmailAddress
        [PSCustomObject]@{
            DisplayName = $user.DisplayName
            PrimarySMTPAddress = $user.EmailAddress
        }
    }
    
    

    Let me know if this working for you.

    Cheers,

    Luis Arias


    If the information helped address your question, please Accept the answer.


  2. Rich Matheisen 47,901 Reputation points
    2023-11-09T16:05:40.7433333+00:00

    I don't have an Exchange server to work with, so I've altered your question to work with AD objects.

    $x=Get-ADGroupMember -Identity groupx 
        ForEach-Object {
            if ($_.objectclass -eq 'user'){
                $_|Get-ADUser -Properties displayname,mail,description
            }
        } 
    $x | ft displayname, mail, description
    "There are $($x.count) members of this group"
    

    If there are other members of the group that are not users (e.g., a contact or other groups) you can remove the "if" statement or substitute one of your own.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.