Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Identity.Governance show configured approvers in AssignmentPolicy overview #649

Closed
BasWassenaar opened this issue Apr 30, 2021 · 4 comments

Comments

@BasWassenaar
Copy link

BasWassenaar commented Apr 30, 2021

Hi! Thanks for the Identity.Governance Module. I have a request.
Our goal
We want to create an overview (.csv-file) where we show the available access packages and who the approvers are.
Possible solution
Option 1
Expand the Get-MgEntitlementManagementAccessPackageAssignmentPolicy command output with the approvers from both stages.
Option 2
Create a separate command to show the approval stage details for a policy.

I hope I didn't miss the command that already does this. :-)

AB#9226

@ghost ghost added the ToTriage label Apr 30, 2021
@ghost ghost added this to Issues to triage in Graph SDK - Triage Apr 30, 2021
@markwahl-msft
Copy link
Contributor

We haven't yet added a cmdlet to do this but it is in our plan. Perhaps try something like this code sample? Send the output to export-csv...



function Add-SplitOfPolicyColumn($aObj,$addl,$key)
{
    if ($addl.ContainsKey($key) -eq $false) {
        $aObj | Add-Member -MemberType NoteProperty -Name $key -Value ""
    }
}

function Write-SplitPolicyApprover($stageObj,$a,$isEscalation)
{
    $addl = $a.AdditionalProperties

    $aObj = $stageObj.PSObject.Copy()

    $aObj | Add-Member -MemberType NoteProperty -Name isBackup -Value $a.isBackup
    $aObj | Add-Member -MemberType NoteProperty -Name isEscalation -Value $isEscalation

    foreach ($k in $addl.Keys) {
        $aObj | Add-Member -MemberType NoteProperty -Name $k -Value $addl[$k] -Force
    }

    Add-SplitOfPolicyColumn $aObj $addl "id"
    Add-SplitOfPolicyColumn $aObj $addl "description"
    Add-SplitOfPolicyColumn $aObj $addl "managerLevel"
    
    write-output $aObj

}

$apall = get-mgentitlementmanagementaccesspackage -expandproperty accessPackageAssignmentPolicies -all 

foreach ($ap in $apall) {
    foreach ($p in $ap.AccessPackageAssignmentPolicies) {
        if ($p.RequestApprovalSettings) {
            if ($p.RequestApprovalSettings.ApprovalStages) {
                $stageCount = $p.RequestApprovalSettings.ApprovalStages.Count

                $stageNumber = 0
                while ($stageNumber -lt $stageCount) {

                    $thisStage = $p.RequestApprovalSettings.ApprovalStages[$stageNumber]
                    $stageNumber++


                    $stageObj = [pscustomobject]@{
                        accessPackageId = $ap.id
                        policyId = $p.id
                        stageCount = $stageCount
                        stageNumber = $stageNumber
                    }

                    if ($thisStage.PrimaryApprovers) {
                        foreach ($a in $thisStage.PrimaryApprovers) {
                            Write-SplitPolicyApprover $stageObj $a $false
                        }
                    }

                    if ($thisStage.EscalationApprovers) {
                        foreach ($a in $thisStage.EscalationApprovers) {
                            Write-SplitPolicyApprover $stageObj $a $true
                        }
                    }
                }
            }
        }
    }
}

@BasWassenaar
Copy link
Author

Thanks Mark, this was really helpful! Do you want me to close this or leave it here for future reference?

@peombwa
Copy link
Member

peombwa commented May 21, 2021

Thanks @markwahl-msft. Can I add this sample to our samples - https://github.com/microsoftgraph/msgraph-sdk-powershell/tree/dev/samples?

@BasWassenaar, we can close this once we've added it to our samples.

@peombwa peombwa removed this from Issues to triage in Graph SDK - Triage May 21, 2021
@peombwa peombwa added this to To do in Graph SDK - Powershell via automation May 21, 2021
@peombwa peombwa self-assigned this May 21, 2021
@markwahl-msft
Copy link
Contributor

I do not think this should be in samples as the above was an excerpt from a cmdlet that we are waiting to integrate into custom path, once the prerequisites have been addressed in this module.

@peombwa peombwa closed this as completed Feb 23, 2022
Graph SDK - Powershell automation moved this from To do to Done Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants