Skip to content

New command: aad group user list #5469

@milanholemans

Description

@milanholemans

New specs

We've created new specs because there was a confusion with the old specs around member roles and user types. userType (Members VS Guests) is an AAD related user property, while Owners VS Members is the role the user has in the group.

The changes specs:

Usage

m365 aad group user list [options]

Description

Lists users of a specific Azure AD group

Options

Option Description
-i, --groupId [groupId] The ID of the Azure AD group. Specify groupId or groupDisplayName but not both.
-n, --groupDisplayName [groupDisplayName] The display name of the Azure AD group. Specify groupId or groupDisplayName but not both.
-r, --role [role] Filter the results to only users with the given role: Owner or Member.
-p, --properties [properties] Comma-separated list of properties to retrieve.
-f, --filter [filter] OData filter to use to query the list of users with.

Examples

List all group users from a group specified by ID

m365 aad group user list --groupId 03cba9da-3974-46c1-afaf-79caa2e45bbe

List all owners from a group specified by display name

m365 aad group user list --groupDisplayName Developers --role Owner

List specific properties for all group users from a group specified by ID

m365 aad group user list --groupId 03cba9da-3974-46c1-afaf-79caa2e45bbe --properties 'id,jobTitle,companyName,accountEnabled'

List all group members that are guest users

m365 aad group user list --groupDisplayName Developers --filter "userType eq 'Guest'"

Default properties

  • id
  • displayName
  • userPrincipalName
  • roles (custom property)

Additional Info

  • in the api call we $select the userName, id, displayName, given name and surname by default.

  • When using the --properties option, default properties will not be added to the $select parameter, unless mentioned

  • Just like in similar commands, using a property with a slash should translate to an added $expand-parameter.

  • we add a roles property to the items in the response output to show that users are member, owner or both.

More information

View the documentation to see what userproperties can be included: https://pnp.github.io/cli-microsoft365/cmd/aad/user/user-get#more-information

Old Specs

Usage

m365 aad group user list [options]

Description

Lists users of a specific Azure AD group

Options

Option Description
-i, --groupId [groupId] The ID of the Azure AD group. Specify groupId or groupDisplayName but not both.
-n, --groupDisplayName [groupDisplayName] The display name of the Azure AD group. Specify groupId or groupDisplayName but not both.
-r, --role [role] Filter the results to only users with the given role: Owner, Member or Guest.

Examples

List all group users from a group specified by ID

m365 aad group user list --groupId 03cba9da-3974-46c1-afaf-79caa2e45bbe

List all owners from a group specified by display name

m365 aad group user list --groupDisplayName Developers --role Owner

Default properties

  • id
  • displayName
  • userPrincipalName
  • userType

Additional Info

  • In the API we should explicitly select the property userType otherwise it will not be returned.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions