Powershell – List group Memberships in 365 of Distribution groups and Unified groups

 

$groups=Get-UnifiedGroup

foreach($group in $groups)
{
    Write-Host "************************************************"
    Write-Host "GroupName: "  $group.DisplayName
    Write-Host "Email: "  $group.primarySMTPAddress
    Write-Host "--- Members ---"
    $membersOfGroup=Get-UnifiedGroupLinks -Identity $group.Identity -LinkType Members
    foreach($member in $membersOfGroup)
    {       
        Get-Recipient -Identity $member.Name | select PrimarySmtpAddress |Format-Wide 
    }
     
}


$groups=Get-DistributionGroup

foreach($group in $groups)
{
    Write-Host "************************************************"
    Write-Host "GroupName: "  $group.DisplayName
    Write-Host "Email: "  $group.primarySMTPAddress
    Write-Host "--- Members ---"
    $membersOfGroup=Get-DistributionGroupMember -Identity $group.Identity
    foreach($member in $membersOfGroup)
    {       
        Get-Recipient -Identity $member.Name | select PrimarySmtpAddress |Format-Wide 
    }
     
}
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Trackback from your site.