Skip to content

Commit

Permalink
Fixes retrieving distribution groups. Closes pnp#6529
Browse files Browse the repository at this point in the history
  • Loading branch information
milanholemans committed Dec 21, 2024
1 parent c856e6e commit 231a228
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/m365/entra/commands/group/group-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
5 changes: 3 additions & 2 deletions src/m365/entra/commands/group/group-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 231a228

Please sign in to comment.