|
| 1 | +--- |
| 2 | +title: List deny assignments for Azure resources using Azure PowerShell | Microsoft Docs |
| 3 | +description: Learn how to list the users, groups, service principals, and managed identities that have been denied access to specific Azure resource actions at particular scopes using Azure PowerShell. |
| 4 | +services: active-directory |
| 5 | +documentationcenter: '' |
| 6 | +author: rolyon |
| 7 | +manager: mtillman |
| 8 | + |
| 9 | +ms.service: role-based-access-control |
| 10 | +ms.devlang: na |
| 11 | +ms.topic: conceptual |
| 12 | +ms.tgt_pltfrm: na |
| 13 | +ms.workload: identity |
| 14 | +ms.date: 06/12/2019 |
| 15 | +ms.author: rolyon |
| 16 | +ms.reviewer: bagovind |
| 17 | +--- |
| 18 | + |
| 19 | +# List deny assignments for Azure resources using Azure PowerShell |
| 20 | + |
| 21 | +[Deny assignments](deny-assignments.md) block users from performing specific Azure resource actions even if a role assignment grants them access. This article describes how to list deny assignments using Azure PowerShell. |
| 22 | + |
| 23 | +> [!NOTE] |
| 24 | +> You can't directly create your own deny assignments. For information about how deny assignments are created, see [Deny assignments](deny-assignments.md). |
| 25 | +
|
| 26 | +## Prerequisites |
| 27 | + |
| 28 | +To get information about a deny assignment, you must have: |
| 29 | + |
| 30 | +- `Microsoft.Authorization/denyAssignments/read` permission, which is included in most [built-in roles for Azure resources](built-in-roles.md) |
| 31 | +- [PowerShell in Azure Cloud Shell](/azure/cloud-shell/overview) or [Azure PowerShell](/powershell/azure/install-az-ps) |
| 32 | + |
| 33 | +## List deny assignments |
| 34 | + |
| 35 | +### List all deny assignments |
| 36 | + |
| 37 | +To list all deny assignments for the current subscription, use [Get-AzDenyAssignment](/powershell/module/az.resources/get-azdenyassignment). |
| 38 | + |
| 39 | +```azurepowershell |
| 40 | +Get-AzDenyAssignment |
| 41 | +``` |
| 42 | + |
| 43 | +```Example |
| 44 | +PS C:\> Get-AzDenyAssignment |
| 45 | +
|
| 46 | +Id : 22222222-2222-2222-2222-222222222222 |
| 47 | +DenyAssignmentName : Deny assignment '22222222-2222-2222-2222-222222222222' created by Blueprint Assignment |
| 48 | + '/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Blueprint/blueprintAssignments/assignment-locked-storageaccount-TestingBPLocks'. |
| 49 | +Description : Created by Blueprint Assignment '/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Blueprint/blueprintAssignments/assignment-locked-storageaccount-TestingBPLocks'. |
| 50 | +Actions : {*} |
| 51 | +NotActions : {*/read} |
| 52 | +DataActions : {} |
| 53 | +NotDataActions : {} |
| 54 | +Scope : /subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/TestingBPLocks |
| 55 | +DoNotApplyToChildScopes : True |
| 56 | +Principals : { |
| 57 | + DisplayName: All Principals |
| 58 | + ObjectType: SystemDefined |
| 59 | + ObjectId: 00000000-0000-0000-0000-000000000000 |
| 60 | + } |
| 61 | +ExcludePrincipals : { |
| 62 | + ObjectType: ServicePrincipal |
| 63 | + } |
| 64 | +IsSystemProtected : True |
| 65 | +
|
| 66 | +Id : 33333333-3333-3333-3333-333333333333 |
| 67 | +DenyAssignmentName : Deny assignment '33333333-3333-3333-3333-333333333333' created by Blueprint Assignment |
| 68 | + '/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Blueprint/blueprintAssignments/assignment-locked-storageaccount-TestingBPLocks'. |
| 69 | +Description : Created by Blueprint Assignment '/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Blueprint/blueprintAssignments/assignment-locked-storageaccount-TestingBPLocks'. |
| 70 | +Actions : {*} |
| 71 | +NotActions : {*/read} |
| 72 | +DataActions : {} |
| 73 | +NotDataActions : {} |
| 74 | +Scope : /subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/TestingBPLocks/providers/Microsoft.Storage/storageAccounts/storep6vkuxmu4m4pq |
| 75 | +DoNotApplyToChildScopes : True |
| 76 | +Principals : { |
| 77 | + DisplayName: All Principals |
| 78 | + ObjectType: SystemDefined |
| 79 | + ObjectId: 00000000-0000-0000-0000-000000000000 |
| 80 | + } |
| 81 | +ExcludePrincipals : { |
| 82 | + DisplayName: assignment-locked-storageaccount-TestingBPLocks |
| 83 | + ObjectType: ServicePrincipal |
| 84 | + ObjectId: 2311a0b7-657a-4ca2-af6f-d1c33f6d2fff |
| 85 | + } |
| 86 | +IsSystemProtected : True |
| 87 | +``` |
| 88 | + |
| 89 | +### List deny assignments at a resource group scope |
| 90 | + |
| 91 | +To list all deny assignments at a resource group scope, use [Get-AzDenyAssignment](/powershell/module/az.resources/get-azdenyassignment). |
| 92 | + |
| 93 | +```azurepowershell |
| 94 | +Get-AzDenyAssignment -ResourceGroupName <resource_group_name> |
| 95 | +``` |
| 96 | + |
| 97 | +```Example |
| 98 | +PS C:\> Get-AzDenyAssignment -ResourceGroupName TestingBPLocks | FL DenyAssignmentName, Scope |
| 99 | +
|
| 100 | +DenyAssignmentName : Deny assignment '22222222-2222-2222-2222-222222222222' created by Blueprint Assignment |
| 101 | + '/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Blueprint/blueprintAssignments/assignment-locked-storageaccount-TestingBPLocks'. |
| 102 | +Scope : /subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/TestingBPLocks |
| 103 | +Principals : { |
| 104 | + DisplayName: All Principals |
| 105 | + ObjectType: SystemDefined |
| 106 | + ObjectId: 00000000-0000-0000-0000-000000000000 |
| 107 | + } |
| 108 | +``` |
| 109 | + |
| 110 | +### List deny assignments at a subscription scope |
| 111 | + |
| 112 | +To list all deny assignments at a subscription scope, use [Get-AzDenyAssignment](/powershell/module/az.resources/get-azdenyassignment). To get the subscription ID, you can find it on the **Subscriptions** blade in the Azure portal or you can use [Get-AzSubscription](/powershell/module/Az.Accounts/Get-AzSubscription). |
| 113 | + |
| 114 | +```azurepowershell |
| 115 | +Get-AzDenyAssignment -Scope /subscriptions/<subscription_id> |
| 116 | +``` |
| 117 | + |
| 118 | +```Example |
| 119 | +PS C:\> Get-AzDenyAssignment -Scope /subscriptions/11111111-1111-1111-1111-111111111111 |
| 120 | +``` |
| 121 | + |
| 122 | +## Next steps |
| 123 | + |
| 124 | +- [Understand deny assignments for Azure resources](deny-assignments.md) |
| 125 | +- [List deny assignments for Azure resources using the Azure portal](deny-assignments-portal.md) |
| 126 | +- [List deny assignments for Azure resources using the REST API](deny-assignments-rest.md) |
0 commit comments