Skip to content

Commit 49941b7

Browse files
committed
Get transitive members
1 parent 030633a commit 49941b7

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ The following can be useful if you have multple Azure ADs or limitations in scop
6969
| AADGroupScopingConfig | 2 | Additional info required to determine groups (filter etc.) | id eq '<objectid>' |
7070
| GroupDeprovisioningMethod | Yes | Determines what to do when source AAD group is deleted | Delete / ConvertToDistributionGroup / PrintWarning / DoNothing |
7171
| ADGroupNamePattern | No | Format string for AD group name, {0} = displayName from AAD, {1} = objectId from AAD, {2} = mailNickname from AAD | {0} ({1}) |
72-
| Environment | No | Azure Environment (default to AzurePublic) | AzureCloud / AzureUSGovernment |
72+
| Environment | No | Azure Environment (default to AzurePublic) | AzureCloud / AzureUSGovernment |
73+
| TransitiveMembers | No | Retrieves a flat list of members from all child groups of the AAD group | true |
7374

7475
1. If AuthenticationMethod is ClientCredentials
7576
2. If AADGroupScopingMethod is GroupMemberOfGroup or AADGroupScopingConfig
@@ -193,4 +194,4 @@ PAM bastion forest support using the AD optional feature for PAM and msDS-Shadow
193194
```
194195
$of = get-ADOptionalFeature -filter "name -eq 'privileged access management feature'"
195196
Enable-ADOptionalFeature $of -scope ForestOrConfigurationSet -target ((Get-ADForest).RootDomain)
196-
```
197+
```

Run.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ $ErrorActionPreference = "Continue" # No need to fail hard anymore. This reduces
9595
Write-Verbose "Processing all memberships"
9696
Foreach($ScopedGroup in $ScopedGroups) {
9797
Write-Verbose " - Processing group '$($ScopedGroup.displayName)' ($($ScopedGroup.id))"
98-
$Members = Get-GraphRequestRecursive -Url "$($graphEndpoints.GraphUrl)/v1.0/groups/$($ScopedGroup.id)/members?`$select=id,userType,displayName,userPrincipalName,onPremisesDistinguishedName,onPremisesImmutableId" -AccessToken $AccessToken
99-
98+
if ($Config.TransitiveMembers -eq 'true') {
99+
$Members = Get-GraphRequestRecursive -Url "$($graphEndpoints.GraphUrl)/v1.0/groups/$($ScopedGroup.id)/transitiveMembers/microsoft.graph.user?`$count=true&`$select=id,userType,displayName,userPrincipalName,onPremisesDistinguishedName,onPremisesImmutableId" -AccessToken $AccessToken -AdditionalHeaders @{ConsistencyLevel = 'eventual' }
100+
} else {
101+
$Members = Get-GraphRequestRecursive -Url "$($graphEndpoints.GraphUrl)/v1.0/groups/$($ScopedGroup.id)/members?`$select=id,userType,displayName,userPrincipalName,onPremisesDistinguishedName,onPremisesImmutableId" -AccessToken $AccessToken
102+
}
103+
100104
# Get all onPremisesDistinguishedName values from AAD, which should be our correct list
101105
$ExpectedADMembers = $Members |
102106
Where-Object onPremisesDistinguishedName |

0 commit comments

Comments
 (0)