Skip to content

Commit 29594e7

Browse files
milanholemansAdam-it
authored andcommitted
Fixes retrieving distribution groups. Closes #6529
1 parent 21cf644 commit 29594e7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/m365/entra/commands/group/group-list.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ describe(commands.GROUP_LIST, () => {
368368

369369
it('lists all distribution groups in the tenant', async () => {
370370
sinon.stub(request, 'get').callsFake(async (opts) => {
371-
if (opts.url === `https://graph.microsoft.com/v1.0/groups?$filter=securityEnabled eq false and mailEnabled eq true`) {
371+
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`) {
372372
return {
373373
"value": [
374374
{

src/m365/entra/commands/group/group-list.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ class EntraGroupListCommand extends GraphCommand {
9292
requestUrl += '?$filter=securityEnabled eq true and mailEnabled eq false';
9393
break;
9494
case 'distribution':
95-
requestUrl += '?$filter=securityEnabled eq false and mailEnabled eq true';
95+
useConsistencyLevelHeader = true;
96+
requestUrl += `?$filter=securityEnabled eq false and mailEnabled eq true and not(groupTypes/any(t:t eq 'Unified'))&$count=true`;
9697
break;
9798
case 'mailEnabledSecurity':
9899
useConsistencyLevelHeader = true;
@@ -139,7 +140,7 @@ class EntraGroupListCommand extends GraphCommand {
139140

140141
if (cli.shouldTrimOutput(args.options.output)) {
141142
groups.forEach((group: ExtendedGroup) => {
142-
if (group.groupTypes && group.groupTypes.length > 0 && group.groupTypes[0] === 'Unified') {
143+
if (group.groupTypes && group.groupTypes.length > 0 && group.groupTypes.includes('Unified')) {
143144
group.groupType = 'Microsoft 365';
144145
}
145146
else if (group.mailEnabled && group.securityEnabled) {

0 commit comments

Comments
 (0)