Last active
August 20, 2020 18:55
-
-
Save hansgafriedzal/53bf7eef100998f14764adb493c6fb26 to your computer and use it in GitHub Desktop.
Get Azure AD applications and their API permissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$searchString = '' | |
$_servicePrincipals = Get-AzureADServicePrincipal -All 1 | |
[PSCustomObject] @{ | |
Applications = Get-AzureADApplication -All 1 -SearchString $searchString | %{ | |
$_requiredResourceAccess = $_.RequiredResourceAccess.ResourceAccess | |
[PSCustomObject] @{ | |
ApplicationName = $_.DisplayName | |
ServicePrincipals = $_servicePrincipals | %{ | |
[PSCustomObject] @{ | |
ServicePrincipalName = $_.DisplayName | |
Permissions = ` | |
($_requiredResourceAccess | where Type -eq Role | ` | |
Compare-Object $_.AppRoles ` | |
-ExcludeDifferent -IncludeEqual ` | |
-Property Id ` | |
-PassThru | %{ | |
[PSCustomObject] @{ | |
Permission = $_.Value | |
Type = "Application" | |
} | |
}) ` | |
+ ` | |
($_requiredResourceAccess | where Type -eq Scope | ` | |
Compare-Object $_.Oauth2Permissions ` | |
-ExcludeDifferent -IncludeEqual ` | |
-Property Id ` | |
-PassThru | %{ | |
[PSCustomObject] @{ | |
Permission = $_.Value | |
Type = "Delegated" | |
} | |
}) | |
} | |
} | ?{$_.Permissions.Count} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment