none
Powershell script for distribution groups and its membership RRS feed

  • Question

  • I am written a power shell script to list all distribution groups and their membership . Here display name of members &  distribution group name are finely displaying but i am not getting alias and primary smtp address, in place of that i am getting {} symbol.....can anyone please tell me where i am wrong.

    $AllDG = Get-ADGroup -Filter {GroupCategory -eq "Distribution"} -Properties Members
    Foreach ($dg in $allDg)
    {
    $Members = get-adgroupMember -Identity $dg
    Foreach ($Member in $members)
    {
    $userObj = New-Object PSObject
    $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $member.PrimarySmtpAddress
    $userObj | Add-Member NoteProperty -Name "Alias" -Value $member.Alias
    $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $member.PrimarySmtpAddress
    $userObj | Add-Member NoteProperty -Name "Distribution Group" -Value $DG.Name
    Write-Output $Userobj
    }


    }

    ; Break


    Friday, May 24, 2019 5:03 AM

All replies