SYNOPSIS
Get-MgRoleReport.ps1 - Reports on Microsoft Entra ID (Azure AD) rolesSYNTAX
DESCRIPTION
By default, the report contains only the roles with members. To get all the role, included empty roles, add -IncludeEmptyRoles $trueEXAMPLES
EXAMPLE 1
EXAMPLE 2
EXAMPLE 3
EXAMPLE 4
PARAMETERS
-IncludeEmptyRoles
Switch parameter to include empty roles in the report-IncludePIMEligibleAssignments
Boolean parameter to include PIM eligible assignments in the report. Default is $true-ForceNewToken
Switch parameter to force getting a new token from Microsoft Graph-MaesterMode
Switch parameter to use with the Maester framework (internal process not presented here)-ProgressAction
{{ Fill ProgressAction Description }}CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.INPUTS
OUTPUTS
The report is output to an array contained all the audit logs found.
To export in a csv, do Get-MgRoleReport | Export-CSV -NoTypeInformation ”$(Get-Date -Format yyyyMMdd)_adminRoles.csv” -Encoding UTF8
NOTES
Written by Bastien Perez (Clidsys.com - ITPro-Tips.com) For more Office 365/Microsoft 365 tips and news, check out ITPro-Tips.com. Version History:[1.8.2] - 2025-10-17
Changed
- Fix
onPremisesSyncEnabledproperty
[1.8.1] - 2025-10-17
Added
- Add
RecommendationSyncproperty
[1.8.0] - 2025-10-08
Added
- Add
IncludeEmptyRolesswitch parameter to get all roles, even the ones without members
Changed
- Use List for mgRoles for better performance
[1.7.0] - 2025-04-04
Changed
- Add scopes for
RoleManagement.Read.AllandAuditLog.Read.Allpermissions
[1.6] - 2025-02-26
Changed
- Add
permissionsNeededvariable - Add
onpremisesSyncEnabledproperty for groups - Add all type objects in the cache array
- Add
LastNonInteractiveSignInDateTimeproperty for users
[1.5.0] - 2025-02-25
Changed
- Always return
trueorfalseforonPremisesSyncEnabledproperties - Fix issues with
objectsCacheArraythat was not working - Sign-in activity tracking for service principals
Plannned for next release
- Switch to
Invoke-MgGraphRequestinstead ofGet-Mg*CMDlets
[1.4.0] - 2025-02-13
Added
- Sign-in activity tracking for users
- Account enabled status.
- On-premises sync enabled status.
- Remove old parameters
- Test if already connected to Microsoft Graph and with the right permissions
[1.3.0] - 2024-05-15
Changed
- Changes not specified.
[1.2.0] - 2024-03-13
Changed
- Changes not specified.
[1.1.0] - 2023-12-01
Changed
- Changes not specified.