LoginSignup
2
1

More than 3 years have passed since last update.

不要なリソースグループを削除するスクリプト備忘録

Posted at

検証などでazureサブスクリプションにリソースを作っていると、リソースが一つもないのに残っているリソースグループが複数できていたりする。そんなサブスクリプション上のゴミリソースグループをまとめて削除するAzure Powershell スクリプト

$resourceGroups = Get-AzureRmResourceGroup
foreach ($rg in $resourceGroups)
{
    $resources = Get-AzureRmResource -ResourceGroupName $rg.ResourceGroupName

    if($resources.count -le 0)
    {
        Remove-AzureRmResourceGroup -Name $rg.ResourceGroupName -AsJob
    }
}
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1