diff --git a/src/m365/entra/commands/group/group-list.spec.ts b/src/m365/entra/commands/group/group-list.spec.ts index 485c4612cc6..72582540028 100644 --- a/src/m365/entra/commands/group/group-list.spec.ts +++ b/src/m365/entra/commands/group/group-list.spec.ts @@ -368,7 +368,7 @@ describe(commands.GROUP_LIST, () => { it('lists all distribution groups in the tenant', async () => { sinon.stub(request, 'get').callsFake(async (opts) => { - if (opts.url === `https://graph.microsoft.com/v1.0/groups?$filter=securityEnabled eq false and mailEnabled eq true`) { + if (opts.url === `https://graph.microsoft.com/v1.0/groups?$filter=securityEnabled eq false and mailEnabled eq true and not(groupTypes/any(t:t eq 'Unified'))&$count=true`) { return { "value": [ { diff --git a/src/m365/entra/commands/group/group-list.ts b/src/m365/entra/commands/group/group-list.ts index 95e7ce0bcf1..c49c0cbbfd4 100644 --- a/src/m365/entra/commands/group/group-list.ts +++ b/src/m365/entra/commands/group/group-list.ts @@ -92,7 +92,8 @@ class EntraGroupListCommand extends GraphCommand { requestUrl += '?$filter=securityEnabled eq true and mailEnabled eq false'; break; case 'distribution': - requestUrl += '?$filter=securityEnabled eq false and mailEnabled eq true'; + useConsistencyLevelHeader = true; + requestUrl += `?$filter=securityEnabled eq false and mailEnabled eq true and not(groupTypes/any(t:t eq 'Unified'))&$count=true`; break; case 'mailEnabledSecurity': useConsistencyLevelHeader = true; @@ -139,7 +140,7 @@ class EntraGroupListCommand extends GraphCommand { if (cli.shouldTrimOutput(args.options.output)) { groups.forEach((group: ExtendedGroup) => { - if (group.groupTypes && group.groupTypes.length > 0 && group.groupTypes[0] === 'Unified') { + if (group.groupTypes && group.groupTypes.length > 0 && group.groupTypes.includes('Unified')) { group.groupType = 'Microsoft 365'; } else if (group.mailEnabled && group.securityEnabled) {