次の方法で共有


Azure PowerShell を使用して Azure ロールの割り当てを一覧表示する

Azure ロールベースのアクセス制御 (Azure RBAC) は、Azure リソースへのアクセスを管理するために使用する承認システムです。 ユーザー、グループ、サービスプリンシパル、またはマネージド ID がアクセスできるリソースを特定するには、ロールの割り当てを一覧表示します。 この記事では、Azure PowerShell を使用してロールの割り当てを一覧表示する方法について説明します。

Azure Az PowerShell モジュールを使用して Azure と対話することをお勧めします。 作業を始めるには、「Azure PowerShell をインストールする」を参照してください。 Az PowerShell モジュールに移行する方法については、「 Azure PowerShell を AzureRM から Az に移行する」を参照してください。

組織で、Azure Lighthouse を使用するサービス プロバイダーに管理機能を外部委託している場合、そのサービス プロバイダーによって承認されているロールの割り当てはここに表示されません。 同様に、サービス プロバイダー テナント内のユーザーには、割り当てられているロールに関係なく、顧客のテナント内のユーザーに対するロールの割り当ては表示されません。

[前提条件]

現在のサブスクリプションのロールの割り当てを一覧表示する

現在のサブスクリプションのすべてのロールの割り当ての一覧を取得する最も簡単な方法 (ルートと管理グループから継承されたロールの割り当てを含む) は、パラメーターを指定せずに Get-AzRoleAssignment を使用することです。

Get-AzRoleAssignment
PS C:\> Get-AzRoleAssignment

RoleAssignmentId   : /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignments/11111111-1111-1111-1111-111111111111
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000
DisplayName        : Alain
SignInName         : alain@example.com
RoleDefinitionName : Storage Blob Data Reader
RoleDefinitionId   : 2a2b9908-6ea1-4ae2-8e65-a410df84e7d1
ObjectId           : 44444444-4444-4444-4444-444444444444
ObjectType         : User
CanDelegate        : False

RoleAssignmentId   : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales/providers/Microsoft.Authorization/roleAssignments/33333333-3333-3333-3333-333333333333
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales
DisplayName        : Marketing
SignInName         :
RoleDefinitionName : Contributor
RoleDefinitionId   : b24988ac-6180-42a0-ab88-20f7382dd24c
ObjectId           : 22222222-2222-2222-2222-222222222222
ObjectType         : Group
CanDelegate        : False

...

サブスクリプションのロールの割り当てを一覧表示する

サブスクリプション スコープですべてのロールの割り当てを一覧表示するには、 Get-AzRoleAssignment を使用します。 サブスクリプション ID を取得するには、Azure portal の [ サブスクリプション ] ブレードで確認するか、 Get-AzSubscription を使用できます。

Get-AzRoleAssignment -Scope /subscriptions/<subscription_id>
PS C:\> Get-AzRoleAssignment -Scope /subscriptions/00000000-0000-0000-0000-000000000000

ユーザーのロールの割り当てを一覧表示する

指定したユーザーに割り当てられているすべてのロールを一覧表示するには、 Get-AzRoleAssignment を使用します。

Get-AzRoleAssignment -SignInName <email_or_userprincipalname>
PS C:\> Get-AzRoleAssignment -SignInName isabella@example.com | FL DisplayName, RoleDefinitionName, Scope

DisplayName        : Isabella Simonsen
RoleDefinitionName : BizTalk Contributor
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

指定したユーザーに割り当てられているすべてのロールと、ユーザーが属するグループに割り当てられているロールを一覧表示するには、 Get-AzRoleAssignment を使用します。

Get-AzRoleAssignment -SignInName <email_or_userprincipalname> -ExpandPrincipalGroups
Get-AzRoleAssignment -SignInName isabella@example.com -ExpandPrincipalGroups | FL DisplayName, RoleDefinitionName, Scope

リソース グループのロールの割り当てを一覧表示する

リソース グループ スコープですべてのロールの割り当てを一覧表示するには、 Get-AzRoleAssignment を使用します。

Get-AzRoleAssignment -ResourceGroupName <resource_group_name>
PS C:\> Get-AzRoleAssignment -ResourceGroupName pharma-sales | FL DisplayName, RoleDefinitionName, Scope

DisplayName        : Alain Charon
RoleDefinitionName : Backup Operator
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

DisplayName        : Isabella Simonsen
RoleDefinitionName : BizTalk Contributor
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

DisplayName        : Alain Charon
RoleDefinitionName : Virtual Machine Contributor
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

管理グループのロールの割り当てを一覧表示する

管理グループ スコープですべてのロールの割り当てを一覧表示するには、 Get-AzRoleAssignment を使用します。 管理グループ ID を取得するには、Azure portal の [管理グループ ] ブレードで確認するか、 Get-AzManagementGroup を使用します。

Get-AzRoleAssignment -Scope /providers/Microsoft.Management/managementGroups/<group_id>
PS C:\> Get-AzRoleAssignment -Scope /providers/Microsoft.Management/managementGroups/marketing-group

リソースのロールの割り当てを一覧表示する

特定のリソースのロールの割り当てを一覧表示するには、 Get-AzRoleAssignment-Scope パラメーターを使用します。 スコープはリソースによって異なります。 スコープを取得するには、パラメーターを指定せずに Get-AzRoleAssignment を実行して、すべてのロールの割り当てを一覧表示し、一覧表示するスコープを見つけることができます。

Get-AzRoleAssignment -Scope "/subscriptions/<subscription_id>/resourcegroups/<resource_group_name>/providers/<provider_name>/<resource_type>/<resource>

次の例は、ストレージ アカウントのロールの割り当てを一覧表示する方法を示しています。 このコマンドでは、このストレージ アカウントに適用されるリソース グループやサブスクリプションなど、より高いスコープでのロールの割り当ても一覧表示されることに注意してください。

PS C:\> Get-AzRoleAssignment -Scope "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/storage-test-rg/providers/Microsoft.Storage/storageAccounts/storagetest0122"

リソースに直接割り当てられているロールの割り当てを一覧表示するだけの場合は、 Where-Object コマンドを使用して一覧をフィルター処理できます。

PS C:\> Get-AzRoleAssignment | Where-Object {$_.Scope -eq "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/storage-test-rg/providers/Microsoft.Storage/storageAccounts/storagetest0122"}

クラシック サービス管理者と共同管理者のロールの割り当てを一覧表示する

クラシック サブスクリプション管理者と共同管理者のロールの割り当てを一覧表示するには、 Get-AzRoleAssignment を使用します。

Get-AzRoleAssignment -IncludeClassicAdministrators

マネージド ID のロールの割り当てを一覧表示する

  1. システム割り当てマネージド ID またはユーザー割り当てマネージド ID のオブジェクト ID を取得します。

    ユーザー割り当てマネージド ID のオブジェクト ID を取得するには、 Get-AzADServicePrincipal を使用できます。

    Get-AzADServicePrincipal -DisplayNameBeginsWith "<name> or <vmname>"
    
  2. ロールの割り当てを一覧表示するには、 Get-AzRoleAssignment を使用します。

    Get-AzRoleAssignment -ObjectId <objectid>
    

次のステップ

Azure PowerShell を使用して Azure ロールを割り当てる