Practically the best powershell script for cleaning up Azure


If you need to clean up all resources in your environment accrous multiple resource groups what do you do?

The answer is you powershell script it!

The following script below is a pretty simple script that wall traverse through your resources in azure and delete them

*Note you may to have to run Connect-Az first to establish a token etc.

Get-AzResourceGroup | ForEach-Object { Remove-AzResource -ResourceId $_.ResourceId -Force }

Other Tips

Make sure to

  • Install-Module Az
  • Import-Module Az
  • Import-Module Az.Accounts