PowerShell module for analyzing Microsoft Graph permissions
Install-Module -Name LeastPrivilegedMSGraph -Repository PSGallery
Import-Module LeastPrivilegedMSGraph
# Initialize and connect
Initialize-LogAnalyticsApi
Connect-EntraService -ClientID $clientId -TenantID $tenantId -ClientSecret $secret -Service "LogAnalytics", "GraphBeta"
# Analyze permissions
$apps = Get-AppRoleAssignment |
Get-AppActivityData -WorkspaceId $workspaceId -Days 30 |
Get-AppThrottlingData -WorkspaceId $workspaceId -Days 30 |
Get-PermissionAnalysis
# Generate report
Export-PermissionAnalysisReport -AppData $apps -OutputPath ".\report.html"
Analyzes Microsoft Graph permissions against actual API usage from Log Analytics to determine the minimal permission set required based on real activity patterns.
Tracks application API usage patterns over configurable time periods, identifying which endpoints are accessed and with what HTTP methods.
Monitors API throttling statistics including 429 errors, success rates, and automatic severity classification to identify performance issues.
Generates beautiful, self-contained HTML reports with filtering, sorting, and detailed visualizations of permission usage and recommendations.
Identifies over-privileged applications with unused permissions and provides actionable recommendations for implementing least privilege access.
Designed for PowerShell pipeline operations with efficient batch processing for analyzing hundreds of applications at once.
LeastPrivilegedMSGraph helps you implement the principle of least privilege for Microsoft Graph API permissions by:
Identify and remove unnecessary permissions to reduce attack surface and improve security posture across all Graph API applications.
Generate evidence-based reports demonstrating least privilege implementation for SOC 2, ISO 27001, and other compliance frameworks.
Optimize permission grants based on actual usage patterns, removing over-privileging while ensuring applications have what they need.
Regularly review permission usage to detect drift, unused apps, and potential security issues before they become problems.
Generate detailed reports with specific permission recommendations to attach to change requests and approval workflows.
Quickly identify which applications have access to sensitive data during security incidents or breach investigations.
The module follows a pipeline-based architecture with six main cmdlets:
Initialize-LogAnalyticsApi - Registers Log Analytics service for authenticationGet-AppRoleAssignment - Retrieves current Microsoft Graph permissions for all applicationsGet-AppActivityData - Enriches applications with API activity from Log AnalyticsGet-AppThrottlingData - Adds throttling statistics and health metricsGet-PermissionAnalysis - Analyzes permissions against activity to determine optimal setExport-PermissionAnalysisReport - Generates interactive HTML reportsApplication.Read.All - To read service principalsAppRoleAssignment.Read.All - To read permission assignmentsLog Analytics Reader role on the workspaceContributions are welcome! This is an open-source project under the MIT License.