Because I’m doing a lot of demos with Azure Policies, I searched how to clean, quickly and easily, my subscription of all these policies. For example, I deployed the following policies on a subscription:
To start, connect to your Azure account, in PowerShell, and select the subscription that you want to clean:
1 2 |
Connect-AzAccount Select-AzSubscription -SubscriptionId "VotreId" |
Execute the following command to clean all of the subscription’s policies:
1 2 |
$policies = Get-AzPolicyAssignment foreach ($policy in $policies){Remove-AzPolicyAssignment -Id $policy.ResourceId} |
When the command has finished, your subscription is empty of policies:
It is an easy command, but one that will save a lot of time.