The following script generates a report with the following output objects "Role", "ResourceRole ObjectID" and "Target ObjectID"
#Install-Module Microsoft.Graph.Beta
Connect-MgGraph -Scopes "User.ReadWrite.All", "Group.ReadWrite.All", "EntitlementManagement.ReadWrite.All"
Import-Module Microsoft.Graph.Beta.Identity.Governance
# Read resource roles, split into individual strings
$ResourceRoles = Get-MgBetaEntitlementManagementAccessPackageAssignmentResourceRole <#-- -all --#> | Select-Object OriginId, OriginSystem, Status
$ResourceRoles_trim = $ResourceRoles.OriginId -split ',\s*' | ForEach-Object Trim
# Create 3 seperate objects
$OutputFile = $ResourceRoles_trim | ForEach-Object {
# start by splitting the string into 3 after `_`
$Type,$ResourceRole,$Target = $_ -split '_'
# create the object
[pscustomobject]@{
"Role" = $Type
"ResourceRole Objectid" = $ResourceRole
"Target Objectid" = $Target
}
}
# Export to CSV
$OutputFile | Export-Csv 'C:\ResourceRoles.csv' -NoTypeInformation
Output:
Role ResourceRole Objectid Target Objectid
---- --------------------- ---------------
Member b4t0fb7b-13fd-4hd2-9663-3a4dd38cg636 3a55dd46-6eed-78dd-7d35-c9derdce5f4c
Member ad9t7vfc-fv5t-466d-f36d-4671dc066ed7 3a55dd46-6eed-78dd-7d35-c9derdce5f4c
My Question is: How to add additional Objects
OriginSystem, Status
...from the
$ResourceRoles = Get-MgBetaEntitlementManagementAccessPackageAssignmentResourceRole <#-- -all --#> | Select-Object OriginId, OriginSystem, Status
request, with the correct connection to ID?
Regards
i have no clue how to add
OriginSystem, Status
...to
pscustomobject
UPDATED ANSWER:
OLD ANSWER:
this should be enough, I think: