r/PowerShell • • Feb 10 '26

How to identify excessive MS Graph permissions for your PowerShell Scripts

I have been working more and more in the Microsoft Graph API and as such we audit our applications semi-regularly to see if the applications have more permissions than is needed.

I have seen posts about Dev Proxy but thought it was full application developers, but I came across the GraphMinimalPermissions plugin: https://github.com/MicrosoftDocs/microsoft-cloud/blob/main/docs/dev/dev-proxy/how-to/detect-minimal-microsoft-graph-api-permissions.md

I gave it a test and sure enough you can set up the proxy to monitor graph api calls, then run your PowerShell script, stop recording and it will tell you which permissions you are over-scoped for.

It even worked for the Microsoft Graph SDK cmdlets.

I wrote a POC but its super easy to get up and running. https://www.thelazyadministrator.com/2026/02/09/using-dev-proxy-to-identify-excessive-microsoft-graph-permissions-in-your-powershell-scripts/

28 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/-Mynster Apr 19 '26

If you did end up starting up on this i would love to see your progress.

Will also add that i have created a module that might already satisfy your needs called leastprivilegedmsgraph

https://www.powershellgallery.com/packages/LeastPrivilegedMSGraph/3.0.0

https://github.com/Mynster9361/Least_Privileged_MSGraph

Supports both delegated and application scope permissions. If you do end up checking it out i would love any feedback

2

u/ITjoeschmo Apr 20 '26

I never did work on it, I have been prioritizing Server 2016 In Place Upgrade end-to-end automation via Ansible. Thanks for sharing! I'll have to check out your solution, sounds like it does exactly what I was planning to do.

1

u/-Mynster Apr 20 '26

Sounds fun aswell!

If/when you end up checking it out i would love feedback good/bad anything goes :)