Cloud and Virtualization Architect and Microsoft MVP. Florent specializes in public, private, and hybrid cloud ecosystems. An MCSE in Private Cloud, he provides technical leadership in Cloud and Datacenter Management. Florent delivers high-authority insights on Azure deployments, virtualization strategy, and optimizing enterprise-scale cloud infrastructure.
Cloud and Virtualization Architect and Microsoft MVP. Florent specializes in public, private, and hybrid cloud ecosystems. An MCSE in Private Cloud, he provides technical leadership in Cloud and Datacenter Management. Florent delivers high-authority insights on Azure deployments, virtualization strategy, and optimizing enterprise-scale cloud infrastructure.

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.
Related materials: