Skip to content

Commit

Permalink
Output role assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
jazuntee committed Feb 18, 2022
1 parent 10cc30b commit 2a86c88
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/internal/Export-AADAssessmentReportData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,26 @@ function Export-AADAssessmentReportData {
| Use-Progress -Activity 'Exporting ConsentGrantReport' -Property clientDisplayName -PassThru -WriteSummary `
| Export-Csv -Path (Join-Path $OutputDirectory "ConsentGrantReport.csv") -NoTypeInformation

# [array] $groupTransitiveMembership = Import-Csv -Path (Join-Path $OutputDirectory "groupTransitiveMembers.csv")
# Set-Content -Path (Join-Path $OutputDirectory "roleAssignments.csv") -Value 'roleDefinitionId,directoryScopeId,memberType,assignmentType,endDateTime,principalId,principalType'
# Import-Csv -Path (Join-Path $OutputDirectory "roleAssignmentsData.csv") `
# | Use-Progress -Activity 'Exporting Role Assignments' -Property roleDefinitionId -PassThru -WriteSummary `
# | ForEach-Object {
# $_
# if ($_.principalType -eq "group") {
# $groupId = $_.principalId
# # prefill resulting assignment
# $resultingAssignement = $_
# $resultingAssignement.memberType = "Group"
# $resultingAssignement.principalType = ""
# $resultingAssignement.principalId = ""
# # look for memberships
# $groupTransitiveMembership | Where-Object { $_.id -eq $groupId } | ForEach-Object {
# $resultingAssignement.principalType = $_.memberType
# $resultingAssignement.principalId = $_.memberId
# $resultingAssignement
# }
# }
# } `
# | Export-Csv -Path (Join-Path $OutputDirectory "roleAssignments.csv") -NoTypeInformation
[array] $groupTransitiveMembership = Import-Csv -Path (Join-Path $OutputDirectory "groupTransitiveMembers.csv")
Set-Content -Path (Join-Path $OutputDirectory "roleAssignments.csv") -Value 'roleDefinitionId,directoryScopeId,memberType,assignmentType,endDateTime,principalId,principalType'
Import-Csv -Path (Join-Path $OutputDirectory "roleAssignmentsData.csv") `
| Use-Progress -Activity 'Exporting Role Assignments' -Property roleDefinitionId -PassThru -WriteSummary `
| ForEach-Object {
$_
if ($_.principalType -eq "group") {
$groupId = $_.principalId
# prefill resulting assignment
$resultingAssignement = $_
$resultingAssignement.memberType = "Group"
$resultingAssignement.principalType = ""
$resultingAssignement.principalId = ""
# look for memberships
$groupTransitiveMembership | Where-Object { $_.id -eq $groupId } | ForEach-Object {
$resultingAssignement.principalType = $_.memberType
$resultingAssignement.principalId = $_.memberId
$resultingAssignement
}
}
} `
| Export-Csv -Path (Join-Path $OutputDirectory "roleAssignments.csv") -NoTypeInformation
}

0 comments on commit 2a86c88

Please sign in to comment.