This repository provides scripts in PowerShell and Python that use Microsoft Graph to identify over-privileged identities in Entra ID.
- Detects accounts and service principals assigned to high-risk roles
- Works with both PowerShell and Python
- Exports results to console and CSV (Python)
- Demonstrates how to use Microsoft Graph for identity governance
- Entra ID Premium P1 or P2
- Microsoft Graph PowerShell SDK or Python MSAL library
- Microsoft 365 tenant with administrative access
- API permissions:
- RoleManagement.Read.All
- Directory.Read.All
- Install Microsoft Graph SDK:
Install-Module -Name Microsoft.Graph -Scope CurrentUser
- Run the script:
./powershell/Get-OverPrivilegedIdentities.ps1
- Install dependencies:
pip install msal requests
- Edit the script and add your Tenant ID, Client ID, and Client Secret.
- Run the script:
python python/get_over_privileged_identities.py
The Python script prints results to the console and exports them to a CSV file with a timestamp in the name.
- Review privileged role assignments
- Remove unnecessary privileges
- Implement Entra ID Privileged Identity Management (PIM)
- Automate reporting with scheduled tasks, CI/CD, or cron jobs
MIT License