pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
919 stars 325 forks source link

New command: `m365 entra user groupmembership list` #5904

Closed MartinM85 closed 5 months ago

MartinM85 commented 7 months ago

Usage

m365 entra user groupmembership list [options]

Description

Retrieves all groups where the user is a member of

Options

Option Description
-i, --userId [userId] The ID of the user to retrieve information for. Use either userId, userName or userEmail, but not multiple.
-n, --userName [userName] The name of the user to retrieve information for. Use either userId, userName or userEmail, but not multiple.
-e, --userEmail [userEmail] The email of the user to retrieve information for. Use either userId, userName or userEmail, but not multiple.
--securityEnabledOnly [securityEnabledOnly] Specifies that only security groups that the user is a member of should be returned

Examples

Retrieves groups that the user is a member of

m365 entra user groupmembership list --userId '1caf7dcd-7e83-4c3a-94f7-932a1299c844'

Retrieves only security groups that the user is a member of

m365 entra user groupmembership list --userName 'john.doe@contoso.com' --securityEnabledOnly

Retrieves groups where the currently logged user is a member of

m365 entra user groupmembership list--userId "@meId"

Retrieves groups where the currently logged user is a member of

m365 entra user groupmembership list --userName "@meUserName"

Default properties

No response

Additional Info

The response contains a list of group ids

[
  "123abc24-1234-415e-abcd-012ab20243d8",
  "987cba80-abcd-1234-a9a8-5e6cea73cdbb"
]

https://learn.microsoft.com/en-us/graph/api/directoryobject-getmembergroups?view=graph-rest-1.0&tabs=http

I will work on it

milanholemans commented 7 months ago

Good suggestion @MartinM85, few comments:

I also doubt naming it entra user group list or entra user groupmembership list. What are your thoughts @pnp/cli-for-microsoft-365-maintainers?

MartinM85 commented 7 months ago
milanholemans commented 7 months ago
  • According to the doc, with flag it will return security-enabled groups

Ok, let's fix the description then because now we're saying that it only returns security groups.

* not sure how `text`, `csv` and `md` format the array of string, I've never used any command that returns only array of strings/numbers

Well, I can't think of a command right now that has a familiar output. Let's see what these responses will look like while developing the command.