Skip to content

Commit

Permalink
commented out write-warning debug messages for Get-PrivilegedUser
Browse files Browse the repository at this point in the history
  • Loading branch information
tkol2022 committed Sep 26, 2024
1 parent 29a6421 commit 3a49c49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 6 additions & 4 deletions PowerShell/ScubaGear/Modules/Providers/ExportAADProvider.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ function LoadObjectDataIntoPrivilegedUserHashtable {
[Parameter()]
[int]$Recursioncount = 0
)
Write-Warning "Recursion level: $recursioncount"
# Write-Warning "Recursion level: $recursioncount"

# We support group nesting up to 2 levels deep (stops after processing levels 0 and 1).
# Safeguard: Also protects against infinite loops if there is a circular group assignment in PIM.
if ($recursioncount -ge 2) {
Expand Down Expand Up @@ -382,7 +383,7 @@ Write-Warning "Recursion level: $recursioncount"
if (-Not $PrivilegedUsers.ContainsKey($ObjectId)) {
$AADUser = Get-MgBetaUser -ErrorAction Stop -UserId $ObjectId
$PrivilegedUsers[$ObjectId] = @{"DisplayName"=$AADUser.DisplayName; "OnPremisesImmutableId"=$AADUser.OnPremisesImmutableId; "roles"=@()}
Write-Warning "Processing role: $($RoleName) User: $($AADUser.DisplayName)"
# Write-Warning "Processing role: $($RoleName) User: $($AADUser.DisplayName)"
}
# If the current role has not already been added to the user's roles array then add the role
if ($PrivilegedUsers[$ObjectId].roles -notcontains $RoleName) {
Expand All @@ -395,7 +396,7 @@ Write-Warning "Processing role: $($RoleName) User: $($AADUser.DisplayName)"
$GroupId = $ObjectId
# Get all of the group members that are transitively assigned to the current role via group membership
$GroupMembers = Get-MgBetaGroupMember -All -ErrorAction Stop -GroupId $GroupId
Write-Warning "Processing role: $($RoleName) Group: $($GroupId)"
# Write-Warning "Processing role: $($RoleName) Group: $($GroupId)"

foreach ($GroupMember in $GroupMembers) {
$Membertype = $GroupMember.AdditionalProperties."@odata.type" -replace "#microsoft.graph."
Expand All @@ -422,7 +423,8 @@ Write-Warning "Processing role: $($RoleName) Group: $($GroupId)"
"M365Environment" = $M365Environment }
$PIMGroupMembers = Invoke-GraphDirectly @graphArgs
foreach ($GroupMember in $PIMGroupMembers) {
Write-Warning "Processing role: $($RoleName) PIM group Eligible member: $($GroupMember.PrincipalId)"
# Write-Warning "Processing role: $($RoleName) PIM group Eligible member: $($GroupMember.PrincipalId)"

# If the user is not a member of the PIM group (i.e. they are an owner) then skip them
if ($GroupMember.AccessId -ne "member") { continue }
$PIMEligibleUserId = $GroupMember.PrincipalId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ InModuleScope ExportAADProvider {

# Simulate the "Request_ResourceNotFound" exception
Mock Get-MgBetaDirectoryObject {
# Write-Host "Inside Get-MgBetaDirectoryObject"
throw [System.Exception]::new("Request_ResourceNotFound")
}

Expand Down

0 comments on commit 3a49c49

Please sign in to comment.