Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes retrieving distribution groups #6530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading