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 
    }
     
}
GD Star Rating
loading...
GD Star Rating
loading...

Trackback from your site.