Entra / Microsoft 365 · Applications
Find Graph permissions for cmdlets
Return the Graph permissions needed to run a set of cmdlets, typically those used in a script.
Connect & set up
Run these once per session. All scopes are read-only unless the script makes changes.
# Review required modules and connection steps before running.# Connect to Microsoft Graph or Exchange Online as needed for this script.
Run it
The main script. Copy it, or download the .ps1 and run it from your console.
[array]$InputCmdlets = "Get-MgUser", "Get-MgGroup", "New-MgPlannerTask"[array]$RequiredPermissions = $nullForEach ($Command in $InputCmdlets) {$Permissions = (Find-MgGraphCommand -Command $Command | Select-Object -ExpandProperty Permissions).NameForEach ($Permission in $Permissions) {If ($Permission -notin $RequiredPermissions) {$RequiredPermissions += $Permission}}}Write-Host ("To use these {0} cmdlets, you need the following permissions: {1}" -f ($InputCmdlets -join ", "), ($RequiredPermissions -join ", "))
Attribution
Author
Office365itpros