I’ll be the first to admin, my dev tenant goes between two stages, messy or a disaster. When creating new scripts (especially my copy policy script), I’ll be testing them and end up with duplicate policies, faulty policies or if I have a runaway script, potentially many many duplicate applications.
Every now and then it reaches the point where it needs cleaning up to be manageable. I could go through the GUI, but that’s a lot of clicking about between menus to find everything.
Using my copy script as a very rough base, here is my new script to bulk delete items.
As usual, it’s available on github here
Install-Script -Name bulk-delete-intune
When you run the script, it will go and loop through your environment and give a popup screen with a list of:
- Policies (ADMX, Settings Catalog, Device Restrictions etc.)
- Security Policies
- Compliance Policies
- Conditional Access Policies
- Proactive Remediations
- Azure AD Groups (not on-prem synchronised ones)
- Autopilot Profile
- Autopilot ESP
As you can see, the fourth column shows what each item is in case you have used the same name twice.
This has full support for multiple selection using arrays so Ctrl or Shift-click to select multiple
Then simply click OK and it will loop through and delete anything selected
Obviously be careful with this and if you don’t have any sort of backups in place, for anything other than a dev tenant, I would advise sorting those first (guide here)