I want to delete all the resource groups in a subscription in a single cli command. I used pipeline operator to delete all the resource groups:
(Get-AzResourceGroup | Remove-AzResourceGroup).
While azure deletes the groups sequentially, it prompts for confirmation for each resource group. Is there a way to force delete all resource groups in Azure cli without encountering the confirmation from the CLI.
CodePudding user response:
Please use -Force
parameter to remove resource group without confirmation.
From this link
:
Get-AzResourceGroup -Name "ContosoRG01" | Remove-AzResourceGroup -Force
This command uses the Get-AzResourceGroup cmdlet to get the resource group ContosoRG01, and then passes it to Remove-AzResourceGroup by using the pipeline operator. The Force parameter suppresses the confirmation prompt.