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:
Connect-AzAccount
Select-AzSubscription -SubscriptionId "VotreId"
Execute the following command to clean all of the subscription’s policies:
$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.