Created
September 3, 2023 12:05
-
-
Save charbonnierg/5bb91ba9b3b9716fa0dac88bb1e8b82b to your computer and use it in GitHub Desktop.
Remove Azure RBAC with unknown 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
#!/usr/bin/env bash | |
set -euo pipefail | |
ROLES=$(az role assignment list --query '[].{id:id, principalName:principalName}' --all) | |
IDS=$(echo $ROLES | jq -r '.[] | select(.principalName == "") | .id') | |
for ID in $IDS; do | |
echo "Removing role with unknown user: $ID" | |
az role assignment delete --ids "$ID" & | |
done | |
wait $(jobs -p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment