-
-
Save yamakadi/8b884b417b5ea1d041455949415d18fa to your computer and use it in GitHub Desktop.
PowerShell 3-liner to find roles attached to your current user
This file contains 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
# Get a token and split out the payload | |
$token = ((Get-AzAccessToken).Token).Split(".")[1].Replace('-', '+').Replace('_', '/') | |
# Add padding, if needed | |
while ($token.Length % 4) {$token += "="} | |
# Base64 Decode, convert from json, extract OID, pass into filter for Get-AzRoleAssignment to find current roles | |
Get-AzRoleAssignment | where ObjectId -EQ ([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($token)) | ConvertFrom-Json).oid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment