azuread_account_provisioning_activity_report_reviewedazuread_admin_consent_workflow_enabledazuread_admin_user_mfa_enabledazuread_all_user_mfa_enabledazuread_audit_log_search_enabledazuread_authorization_policy_accessing_company_data_not_allowedazuread_global_admin_range_restrictedazuread_group_not_publicazuread_guest_user_infoazuread_legacy_authentication_disabledazuread_microsoft_azure_management_limited_to_administrative_rolesazuread_password_protection_enabledazuread_risky_sign_ins_reportazuread_security_default_disabledazuread_signin_frequency_policyazuread_signin_risk_policyazuread_third_party_application_not_allowedazuread_user_password_not_set_to_expireazuread_user_risk_policyazuread_user_sspr_enabledmicrosoft365_calendar_sharing_disabled
Query: azuread_global_admin_range_restricted
Usage
powerpipe query microsoft365_compliance.query.azuread_global_admin_range_restricted
Steampipe Tables
SQL
with global_administrator_counts as ( select role.tenant_id, role._ctx, count(*) from azuread_directory_role as role, jsonb_array_elements_text(member_ids) as m_id, azuread_user as u where u.id = m_id and role.display_name ='Global Administrator' group by role.tenant_id, role._ctx)select tenant_id as resource, case when count >= 2 and count <= 4 then 'ok' else 'alarm' end as status, tenant_id || ' has ' || count || ' global administrators.' as reason , tenant_id as tenant_idfrom global_administrator_counts;
Controls
The query is being used by the following controls: