Skip to content

Commit 58cf871

Browse files
committed
Adding Transitive parameter to Get-PnPAzureADGroupMember
1 parent 7ed74a3 commit 58cf871

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

documentation/Get-PnPAzureADGroupMember.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Gets members of a particular Azure Active Directory group. This can be a securit
2020
## SYNTAX
2121

2222
```powershell
23-
Get-PnPAzureADGroupMember -Identity <AzureADGroupPipeBind> [-Connection <PnPConnection>]
23+
Get-PnPAzureADGroupMember -Identity <AzureADGroupPipeBind> [-Connection <PnPConnection>] [-Transitive]
2424
```
2525

2626
## DESCRIPTION
@@ -34,14 +34,21 @@ Allows to list members from given Azure Active Directory group. This can be a se
3434
Get-PnPAzureADGroupMember -Identity $groupId
3535
```
3636

37-
Retrieves all the members of a specific Azure Active Directory group based on its ID.
37+
Retrieves all the direct members of a specific Azure Active Directory group based on its ID.
3838

3939
### EXAMPLE 2
4040
```powershell
4141
Get-PnPAzureADGroupMember -Identity $group
4242
```
4343

44-
Retrieves all the members of a specific Azure Active Directory group based on the group's object instance.
44+
Retrieves all the direct members of a specific Azure Active Directory group based on the group's object instance.
45+
46+
### EXAMPLE 3
47+
```powershell
48+
Get-PnPAzureADGroupMember -Identity $group -Transitive
49+
```
50+
51+
Retrieves all the direct and transitive members of a specific Azure Active Directory group based on the group's object instance.
4552

4653
## PARAMETERS
4754

@@ -73,6 +80,20 @@ Accept pipeline input: False
7380
Accept wildcard characters: False
7481
```
7582
83+
### -Transitive
84+
The direct and transitive members of a group
85+
86+
```yaml
87+
Type: SwitchParameter
88+
Parameter Sets: (All)
89+
90+
Required: False
91+
Position: Named
92+
Default value: None
93+
Accept pipeline input: False
94+
Accept wildcard characters: False
95+
```
96+
7697
## RELATED LINKS
7798
7899
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

src/Commands/AzureAD/GetAzureADGroupMember.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public class GetAzureADGroupMember : PnPGraphCmdlet
1818
[Parameter(Mandatory = true, ValueFromPipeline = true)]
1919
public AzureADGroupPipeBind Identity;
2020

21+
[Parameter(Mandatory = false, ValueFromPipeline = false)]
22+
public SwitchParameter Transitive;
23+
2124
protected override void ExecuteCmdlet()
2225
{
2326
Group group = null;
@@ -30,8 +33,11 @@ protected override void ExecuteCmdlet()
3033
if (group != null)
3134
{
3235
// Get members of the group
33-
var members = Microsoft365GroupsUtility.GetMembers(GraphRequestHelper, new Guid(group.Id));
34-
WriteObject(members?.OrderBy(m => m.DisplayName), true);
36+
var members = Transitive
37+
? Microsoft365GroupsUtility.GetTransitiveMembers(GraphRequestHelper, new Guid(group.Id))
38+
: Microsoft365GroupsUtility.GetMembers(GraphRequestHelper, new Guid(group.Id));
39+
WriteObject(members?.OrderBy(m => m.DisplayName), true);
40+
3541
}
3642
}
3743
}

src/Commands/Utilities/Microsoft365GroupsUtility.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ internal static IEnumerable<Microsoft365User> GetMembers(ApiRequestHelper reques
389389
{
390390
return GetGroupMembers(requestHelper, "members", groupId);
391391
}
392+
393+
internal static IEnumerable<Microsoft365User> GetTransitiveMembers(ApiRequestHelper requestHelper, Guid groupId)
394+
{
395+
return GetGroupMembers(requestHelper, "transitiveMembers", groupId);
396+
}
392397

393398
private static IEnumerable<Microsoft365User> GetGroupMembers(ApiRequestHelper requestHelper, string userType, Guid groupId)
394399
{

0 commit comments

Comments
 (0)