You cannot check the group type from Azure AD, if you want to check it, you need to connect to Exchange online at the same time:
Step 1: Connect-AzureAD
Step 2: Connect-ExchangeOnline
Step 3: Run the new script:
$users = Get-Content -Path "C:\input.csv"
ForEach ($user in $users)
{
$memberships = Get-AzureADUserMembership -ObjectId $user | Where-Object {$_.MailEnabled -eq $true}
foreach ($membership in $memberships)
{
$membershipDisplayName = $membership.Displayname
$membershipMailEnabled = $membership.MailEnabled
$membershipObjectType = (Get-DistributionGroup $membership.Displayname).GroupType
$membershipSecurityEnabled = $membership.SecurityEnabled
$membershipMail = $membership.Mail
$out = "$user,$membershipDisplayName,$membershipMailEnabled,$membershipObjectType,$membershipSecurityEnabled,$membershipMail"
$out | Out-File -FilePath C:\temp\output.csv -Append
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.