Skip to content

Instantly share code, notes, and snippets.

@astaykov
Last active December 11, 2019 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astaykov/0911c7b2c1dca09004c70763c7d28a80 to your computer and use it in GitHub Desktop.
Save astaykov/0911c7b2c1dca09004c70763c7d28a80 to your computer and use it in GitHub Desktop.
#!/bin/bash
function check_directory_dependencies() {
echo "Checking for graph extension on Azure CLI..."
echo "--------------------------------------------"
PATTERN='resource-graph'
string=$(az extension list | grep 'resource-graph')
if [[ $string == *"resource-graph"* ]];
then
# az extension update --name resource-graph
echo 'Graph extension is already installed...'
else
echo 'Installing az graph extension. Hold on a second...'
az extension add --name resource-graph
fi
echo " "
echo "Azure resources with known Azure AD Tenant dependencies:"
echo "--------------------------------------------------------"
subscriptionId=$(az account show --query id | sed -e 's/^"//' -e 's/"$//')
az graph query -q 'resources | where type != "microsoft.azureactivedirectory/b2cdirectories" | where identity <> "" or properties.tenantId <> "" or properties.encryptionSettingsCollection.enabled == true | project name, type, kind, identity, tenantId, properties.tenantId' --subscriptions $subscriptionId --output table
echo " "
echo "Azure SQL Servers with Azrue AD Authentication"
echo "----------------------------------------------"
az sql server ad-admin list --ids $(az graph query -q 'resources | where type == "microsoft.sql/servers" | project id' -o tsv | cut -f1)
# for resourceId in $(az graph query -q 'resources | where type == "microsoft.sql/servers" | project id' -o tsv | cut -f1)
# do
# az sql server ad-admin list --ids $resourceId -o table
# done
echo "RBAC role assignments:"
echo "----------------------"
az role assignment list --all -o table
}
check_directory_dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment