Created
March 24, 2023 09:07
-
-
Save LuemmelSec/726307e7dc62dbbf1330bdf12acd2c5c to your computer and use it in GitHub Desktop.
A simple PowerShell script to check to which apps the user consented to and which permissions were granted
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
# A simple PowerShell script to check to which apps the user consented to and which permissions were granted | |
# Install the required PowerShell modules if they're not already installed | |
Install-Module -Name AzureAD | |
# Connect to Azure AD | |
Connect-AzureAD | |
# Get the user object for the signed-in user. UPN e.g. [email protected] | |
$user = Get-AzureADUser -ObjectId (Get-AzureADUser -SearchString "<your user principal name>").ObjectId | |
# Get the OAuth2PermissionGrants for the user | |
$consents = Get-AzureADUserOAuth2PermissionGrant -ObjectId $user.ObjectId | |
foreach ($consent in $consents) { | |
$app = Get-AzureADServicePrincipal -ObjectId $consent.ClientId | |
Write-Host "App Name: " $($app.DisplayName) | |
Write-Host "App ID: " $($app.AppId) | |
Write-Host "Consent given: " $consent.Scope | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment