Skip to content

Instantly share code, notes, and snippets.

@isjwuk
Created January 30, 2023 09:37
Show Gist options
  • Save isjwuk/63a88bee4fa59d35e359dd9e4ba048d1 to your computer and use it in GitHub Desktop.
Save isjwuk/63a88bee4fa59d35e359dd9e4ba048d1 to your computer and use it in GitHub Desktop.
Find Azure App Service Plans with no App Services associated with them.
<#
.SYNOPSIS
Find empty Azure App Service Plans
.DESCRIPTION
Find Azure App Service Plans in the current Azure Context with no App Services associated with them.
These empty App Service Plans will potentially be incurring unneccessary charges.
.EXAMPLE
#Return a list of Empty App Service Plans in the current Azure Context
Get-AzEmptyAppServicePlans
.EXAMPLE
#Remove any empty App Service Plans in the current Azure Context
Get-AzEmptyAppServicePlans | Remove-AzAppServicePlan
#Append with -Force to bypass confirmation
.EXAMPLE
#List the Name and Resource Group Name of any empty App Service Plans in the current Azure Context
Get-AzEmptyAppServicePlans | Select-Object Name, ResourceGroup
#>
function Get-AzEmptyAppServicePlans{
Return( Get-AzAppServicePlan | Where-Object {$_.NumberOfSites -eq 0})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment