Skip to content

Instantly share code, notes, and snippets.

@RIKIKU
Created January 30, 2017 03:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RIKIKU/592ab1357d376c9d2a9a755fb2eef493 to your computer and use it in GitHub Desktop.
Save RIKIKU/592ab1357d376c9d2a9a755fb2eef493 to your computer and use it in GitHub Desktop.
Remove expired SSL certificates
Login-AzureRmAccount -TenantId "InsertTennantIdHere"
Get-AzureRmSubscription -SubscriptionId "InsertSubscriptionIdHere" | Select-AzureRmSubscription
$certificates = Get-AzureRmResource -ExpandProperties | where ResourceType -EQ Microsoft.Web/certificates #This part takes ages to run.
foreach ($certificate in $certificates)
{
if((get-date $certificate.Properties.expirationDate) -le (Get-Date) )
{
Remove-AzureRmResource -ResourceName $certificate.ResourceName -ResourceType $certificate.ResourceType -ResourceGroupName $certificate.ResourceGroupName -Verbose -Confirm:$false -Force
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment