Hello MURALIDHAR,
To get the Group Types for the groups present in Entra ID like Microsoft 365, Security using Powershell script make use of below PowerShell script:
$groupId = "GroupID"
$g = Get-MgGroup -GroupId $groupId
if ($g.GroupTypes -contains "Unified") {
$type = "Microsoft 365"
}
elseif ($g.MailEnabled -eq $true -and $g.SecurityEnabled -eq $true) {
$type = "Mail-enabled Security"
}
elseif ($g.MailEnabled -eq $true -and $g.SecurityEnabled -eq $false) {
$type = "Distribution"
}
else {
$type = "Security"
}
$g | Select DisplayName, Mail, MailEnabled, SecurityEnabled, GroupTypes, @{Name="GroupType";Expression={$type}}
To iterate through all groups, use below script:
Connect-MgGraph -Scopes "Group.Read.All"
$groups = Get-MgGroup -All
$results = foreach ($g in $groups) {
if ($g.GroupTypes -contains "Unified") {
$type = "Microsoft 365"
}
elseif ($g.MailEnabled -eq $true -and $g.SecurityEnabled -eq $true) {
$type = "Mail-enabled Security"
}
elseif ($g.MailEnabled -eq $true -and $g.SecurityEnabled -eq $false) {
$type = "Distribution"
}
else {
$type = "Security"
}
[PSCustomObject]@{
DisplayName = $g.DisplayName
Mail = $g.Mail
MailEnabled = $g.MailEnabled
SecurityEnabled = $g.SecurityEnabled
GroupTypes = if ($g.GroupTypes) { $g.GroupTypes -join "," } else { "" }
GroupType = $type
Id = $g.Id
}
}
$results | Sort-Object DisplayName | Format-Table -AutoSize
Hope this helps!
If this answers your query, do click Accept Answer and Yes, if you have any further queries do let us know.
If you have any other questions, let me know in the “comments” and I would be happy to help you.