Skip to main content

List All Groups

Retrieves a list of all groups from Azure Active Directory.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Inputs

  • Access Id - The access ID from the Connect node. Optional if using direct credentials.

Options

Direct Credentials (optional - alternative to using Connect node):

  • Tenant Id - Azure AD tenant ID (optional if using Access ID)
  • Client Id - Azure AD application client ID (optional if using Access ID)
  • Client Secret - Azure AD application client secret credential (optional if using Access ID)

Output

  • Result - Object containing an array of group objects in the value property. Each group object includes:
    • id - Group's unique object ID
    • displayName - Group's display name
note

This node returns a limited set of properties (id and displayName) for better performance. Use Get Group to retrieve full details for specific groups.

How It Works

The List All Groups node:

  1. Authenticates using either the access ID or direct credentials
  2. Sends a GET request to Microsoft Graph API with $select=id,displayName parameter
  3. Returns a list of groups with only id and displayName properties
  4. Result contains value array with group objects

Examples

List All Groups

Get all groups in your organization:

// Using Connect node
access_id = message.access_id

// List All Groups node executes

// Output
result = {
"value": [
{
"id": "12345678-1234-1234-1234-123456789012",
"displayName": "Engineering Team"
},
{
"id": "abcdef12-3456-7890-abcd-ef1234567890",
"displayName": "Marketing Team"
},
{
"id": "fedcba98-7654-3210-fedc-ba9876543210",
"displayName": "Sales Team"
}
]
}

Count Total Groups

Get the total number of groups:

// List All Groups node
access_id = message.access_id

// Count groups
total_groups = result.value.length
console.log("Total groups: " + total_groups)

Extract Group Names

Get a list of all group names:

// List All Groups node

// Extract names
group_names = []
for (group of result.value) {
group_names.push(group.displayName)
}

console.log("Groups: " + group_names.join(", "))

Find Group by Name

Search for a specific group:

// List All Groups node

// Search for group
search_name = "Engineering Team"
found_group = null

for (group of result.value) {
if (group.displayName === search_name) {
found_group = group
break
}
}

if (found_group) {
console.log("Found group ID: " + found_group.id)
// Use found_group.id in other nodes
} else {
console.log("Group not found")
}

Create Group Lookup Map

Build a mapping of group names to IDs:

// List All Groups node

// Create lookup map
group_map = {}
for (group of result.value) {
group_map[group.displayName] = group.id
}

// Use the map
engineering_id = group_map["Engineering Team"]
marketing_id = group_map["Marketing Team"]

console.log("Engineering ID: " + engineering_id)

Filter Groups by Naming Pattern

Find groups matching a pattern:

// List All Groups node

// Find all department groups
department_groups = []
for (group of result.value) {
if (group.displayName.endsWith(" Department")) {
department_groups.push(group)
}
}

console.log("Department groups: " + department_groups.length)

Export Groups to CSV

Create a report of all groups:

// List All Groups node

// Prepare CSV data
csv_data = []
csv_data.push(["Group ID", "Group Name"])

for (group of result.value) {
csv_data.push([
group.id,
group.displayName
])
}

// Write CSV node
// Data: csv_data
// File: "groups_report.csv"

Get Detailed Information for All Groups

Retrieve full details for each group:

// List All Groups node

all_group_details = []

// Loop through each group
for (group of result.value) {
// Get Group node
// Group Object Id: group.id

all_group_details.push({
id: result.id,
name: result.displayName,
description: result.description,
type: result.securityEnabled ? "Security" : "Distribution",
mailEnabled: result.mailEnabled
})
}

// Now you have full details for all groups

Sync Groups to External System

Export group list to another system:

// List All Groups node

// Prepare data for external system
groups_for_export = []
for (group of result.value) {
groups_for_export.push({
external_id: group.id,
name: group.displayName
})
}

// Send to external API
// HTTP Request node
// Body: JSON.stringify(groups_for_export)

Tips for Effective Use

  • Limited properties: This node only returns id and displayName for performance
  • Full details: Use Get Group for complete group information
  • Result structure: Groups are in the value array property
  • Search efficiency: Build a lookup map for frequent group name lookups
  • Caching: Store the result if you need to reference it multiple times
  • Naming conventions: Use consistent group naming to make filtering easier
  • Performance: Listing groups is generally faster than listing users

Common Errors and Solutions

"Either Client Secret with Tenant ID and Client ID, or Access ID must be provided"

Cause: Neither access ID nor complete credentials were provided.

Solution:

// Option 1: Use Connect node
access_id = message.access_id

// Option 2: Provide all credentials
tenant_id = "your-tenant-id"
client_id = "your-client-id"
// Set Client Secret option from vault

"Response Status is not OK - Insufficient privileges"

Cause: The application doesn't have permission to read groups.

Solution:

  • Verify your Azure AD app has Group.Read.All or Group.ReadWrite.All permission
  • Ensure admin consent has been granted
  • Check that the permission is an Application permission, not Delegated

No Groups Returned

Cause: Organization has no groups or permissions are insufficient.

Solution:

  • Verify groups exist in your Azure AD directory
  • Check application permissions
  • Try creating a test group to verify setup

Best Practices

  1. Error handling: Wrap List All Groups in Try-Catch blocks
  2. Caching: Store results if needed multiple times in the flow
  3. Lookup maps: Create name-to-ID maps for efficient lookups
  4. Batch processing: Get full details only for groups you need
  5. Logging: Log the operation for audit purposes
  6. Naming standards: Establish group naming conventions for easy filtering
  7. Performance: This is lightweight; use it freely for group discovery
  8. Documentation: Document what groups are used in your automations